What kind of information is displayed by MySQL DESCRIBE statement?


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

Example

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.

Updated on: 22-Jun-2020

43 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements