In this tutorial, we will learn about MySQL DESCRIBE statement with examples. This statement shows a list of columns describing the structure of the specified table.
We can check the structure of a table with the help of DESCRIBE command. The command lets you view a table structure.
The general syntax for the statement is as follows:
mysql> DESC | DESCRIBE <table_name>
mysql> DESCRIBE department;
The DESC command is synonymous with the DESCRIBE command. For example, to know the table structure of the City table from the world MySQL database.
mysql> DESC City;
Let’s understand the output of the command. The output is in a tabular form. The most important fields of the output are as follows:
Field – the Filed column displays the table column names.
Type – the data type of the column, describes the data type of the values that the column holds.
Null – The null ability of the column. The NOT NULL columns are displayed as NO value.
Key – This indicates if the column is a key or index. The value PRI is the PRIMARY KEY for the table. For example, ID is the PRIMARY KEY for the City table.
Default – The default value of the column.
The DESCRIBE or the DESC keyword and EXPLAIN statements are synonyms in MySQL. However, the
DESCRIBE is often used to obtain table structure information. The EXPLAIN keyword is used to obtain the SQL Query execution plan. Execution plan is the information and explanation on how the MySQL would execute the SQL Query.
MySQL Tutorials on this website:
For more information on MySQL Database: