- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6702 Articles for Database
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
2K+ Views
ZEROFILL pads the displayed value of the field with zeros up to the display width set in the column definition. Let us understand the role of zero fill in MySQL using an example. Creating a table with two columns, one has zerofill and the second one does not. The query to create a table. mysql> create table ZeroFillDemo -> ( -> First int(18) zerofill, -> Second int(18) -> ); Query OK, 0 rows affected (0.63 sec) We can insert records in the table with the help ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
6K+ Views
To remove primary key in MySQL, use tje drop primary key command. To understand the concept, let us create a table with column as primary key. mysql> create table PrimaryKeyDemo -> ( -> id int not null, -> Primary key(id) -> ); Query OK, 0 rows affected (0.60 sec) Let us check the description of the table with the help of DESC command. The query is as follows. mysql> desc PrimaryKeyDemo; The following is the output. +-------+---------+------+-----+---------+-------+ | Field | Type ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
5K+ Views
For our example, let us create a table with NOT NULL constraint. After that, we will modify a column to allow NULL. The following is the query to create a table with NOT NULL constraint. mysql> create table AllowNullDemo -> ( -> id int not null -> ); Query OK, 0 rows affected (0.48 sec)= Insert records with the help of INSERT command. The query is as follows. mysql> insert into AllowNullDemo values(); Query OK, 1 row affected, 1 warning (0.19 sec) mysql> insert into AllowNullDemo values(); ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
1K+ Views
You can enable ONLY_FULL_GROUP_BY in MySQL as shown in the following query − mysql> SET sql_mode = 'ONLY_FULL_GROUP_BY'; Query OK, 0 rows affected (0.01 sec) As shown above, we can enable ONLY_FULL_GROUP_BY with the help of SET command. To disable ONLY_FULL_GROUP_BY with the help of the following query − mysql> SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY','')); Query OK, 0 rows affected (0.04 sec) We have disabled ONLY_FULL_GROUP_BY successfully.
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
8K+ Views
The MySQL’s DESCRIBE or DESC both are equivalent. The DESC is the short form of DESCRIBE command and used to dipslay the information about a table like column names and constraints on column name. The DESCRIBE command is equivalent to the following command − SHOW columns from yourTableName command. The following is the query that display information about a table with the help of DESCRIBE command. The query is as follows. mysql> DESCRIBE Student; Above, Student is the table name in my database. The above query generates the following output. +-------+--------------+------+-----+---------+-------+ | Field | Type ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
114 Views
To get the list of MySQL user accounts, we can use “SELECT USER”. The following is the query to display the list. SELECT User FROM mysql.user; Here is the output. +------------------+ | User | +------------------+ | John | | Mac | | Manish | | mysql.infoschema | | mysql.session ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
16K+ Views
We can return 0 for NULL in MySQL with the help of IFNULL() method. The syntax of IFNULL() is as follows. IFNULL(YOUREXPRESSION, 0); Let us see an example. First, we will create a table. mysql> create table NullDemoWithZero -> ( -> id varchar(200) -> ); Query OK, 0 rows affected (0.65 sec) After creating a table, let us insert some records in the table using the INSERT command. The query is as follows − mysql> insert into NullDemoWithZero values(); Query OK, 1 row affected (0.16 sec) ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
3K+ Views
The int type takes 4 byte signed integer i.e. 32 bits ( 232 values can be stored). The BigInt type takes 8 byte signed integer i.e. 64 bits (264 values can be stored). Let us see an example. Creating a table with zerofill, that would add leading zeros. mysql> create table IntandBigint20Demo -> ( -> Number int(20) zerofill, -> Code BigInt(20) zerofill -> ); Query OK, 0 rows affected (0.58 sec) After creating a table, we will insert records into the table. mysql> insert into ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
2K+ Views
Let’s say we have a table and now there is a requirement to add AUTO_INCREMENT on column name. For that, use the MODIFY command. Here, we will create a demo table first. mysql> create table AddingAutoIncrement -> ( -> Id int, -> Name varchar(200), -> Primary key(Id) -> ); Query OK, 0 rows affected (0.47 sec) We have created a table above and now let us alter the table to add AUTO_INCREMENT on column name ‘Id’. The syntax is as follows − ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
342 Views
First, let us create a table with the UNIQUE constraint. It suggests that we cannot add duplicate values. Creating a table. mysql> create table UniqueConstraintDemo -> ( -> Name varchar(200) unique -> ); Query OK, 0 rows affected (1.05 sec) Now, we can check whether the table has UNIQUE constraint or not with the help of DESC command. The query is as follows. mysql> DESC UniqueConstraintDemo; The following is the output. +-------+--------------+------+-----+---------+-------+ | Field | Type | Null ... Read More