Home > Database > Mysql Tutorial > 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?

王林
Release: 2023-09-07 12:25:06
forward
975 people have browsed it

如何通过 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;
Copy after login

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)
Copy after login

The above query will provide " ID" column information.

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

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template