What kind of information is displayed by MySQL DESCRIBE statement?

MySQLMySQLi Database

The DESCRIBE statement gives information about MySQL table’s structure.


Consider the constructing of the following table name ‘Employee’ with Create Table statement as follows −

mysql> Create table Employee(ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, Name Varchar(20));
Query OK, 0 rows affected (0.20 sec)

Now with the help of ‘DESCRIBE Employee‘ statement, we can get the information about the employee table.

mysql> Describe Employee;
| Field | Type        | Null | Key | Default | Extra            |
| ID    | int(11)     | NO   | PRI | NULL    | auto_increment   |
| Name  | varchar(20) | YES  |     | NULL    |                  |
2 rows in set (0.11 sec)

The above description tells us about the name of the column, its data type, whether it can have NULL values or not, by default what kind of values it can store, the key constraint on it, and any other extra information about it like auto_increment.

Published on 21-Feb-2018 17:28:40