Database

MySQL DESCRIBE Statement

MySQL DESCRIBE Statement

In this tutorial, you will learn about MySQL DESCRIBE statement with examples. This statement shows the structure of the database table. For example, a list of columns, its types, constraints describing the structure of the specified table.

DESCRIBE Command

We can check the structure of a table with the help of DESCRIBE command. The command lets you view a table structure.

Syntax

The general syntax for the statement is as follows:

mysql> DESC | DESCRIBE <table_name>

Examples

The sample command to show the structure of the table is as follows:

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;

 

MySQL DESCRIBE Statement

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

MySQL Tutorials on this website: