How can I get the information about a particular column of a table by MySQL DESCRIBE statement?


As we know that DESCRIBE statement will provide the information/structure of the whole table. With the help of DESCRIBE statement along with table name and the column name, we can get the information about that column.

Syntax

DESCRIBE table_name col_name;

Example1

mysql> Describe employee ID;
+-------+---------+------+-----+---------+----------------+
| Field | Type    | Null | Key | Default | Extra          |
+-------+---------+------+-----+---------+----------------+
| ID    | int(11) | NO   | PRI | NULL    | auto_increment |
+-------+---------+------+-----+---------+----------------+
1 row in set (0.11 sec)

The query above will give the information about the column ‘ID’ of a table named ‘employee’.

Example2

mysql> Describe employee name;
+-------+-------------+------+-----+---------+---------+
| Field | Type        | Null | Key | Default | Extra   |
+-------+-------------+------+-----+---------+---------+
| Name  | varchar(20) | YES  |     | NULL    |         |
+-------+-------------+------+-----+---------+---------+
1 row in set (0.03 sec)

The query above will give the information about the other column ‘Name’ of a table named ‘employee'.

Updated on: 22-Jun-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements