Home  >  Article  >  Database  >  How to get information about a specific column in a table through the MySQL DESCRIBE statement?

How to get information about a specific column in a table through the MySQL DESCRIBE statement?

王林
王林forward
2023-09-07 12:25:06903browse

如何通过 MySQL DESCRIBE 语句获取表中特定列的信息?

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

Syntax
DESCRIBE table_name col_name;

Example 1

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 above query will provide " ID" column information.

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

The above query will provide information about another column "Name" of the table named "employee".

The above is the detailed content of How to get information about a specific column in a table through the MySQL DESCRIBE statement?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete