Access to information (field names, field types, comments, etc.) MySQL database table structure

Directly copy queries to understand!

select COLUMN_NAME,DATA_TYPE,COLUMN_COMMENT from information_schema.columns where TABLE_NAME='表名'

or

select COLUMN_NAME,DATA_TYPE,COLUMN_COMMENT from information_schema.COLUMNS where table_name = '表名' and table_schema = '数据库名称';

or

SHOW FULL COLUMNS FROM 表名

information_schema.columns: MySQL database have the information_schema COLUMNS table, which records all the field information table mysql all the libraries, the following table information

COLUMN_NAME: Field Name

DATA_TYPE: Data Types

COLUMN_COMMENT: Notes

Gangster something to say:

  1. https://blog.csdn.net/lkforce/article/details/79557482
  2. https://www.cnblogs.com/cnwhm/p/4314107.html#final
  3. https://blog.csdn.net/qq_38182287/article/details/70880981
SHOW FULL COLUMNS FROM 表名 //获取表结构的所有信息(含注释)

SHOW COLUMNS FROM 表名 //获取表结构的信息

DESCRIBE 数据表名 //获取表结构的信息( 其中DESCRIBE 可已简写成DESC)

DESCRIBE 数据表名 列名 //获取表结构某一列的信息

 

Published 40 original articles · won praise 14 · views 50000 +

Guess you like

Origin blog.csdn.net/qq_41912505/article/details/88847142