显示Fields FROM Mysql Table的注释

Sta*_*arx 51 mysql

SHOW COLUMNS FROM <tablename>给出表中列的所有信息,除外Comments.

如何提取Comments信息?我知道从INFORMATION SCHEMA中提取信息的方法,但是如何将结果组合在一个结果集中?

Nic*_*ssu 112

您可以使用该查询

SHOW FULL COLUMNS FROM <tablename>
Run Code Online (Sandbox Code Playgroud)

如果你不想使用information_schema.


she*_*yan 8

select `column_name`, `column_type`, `column_default`, `column_comment`
from `information_schema`.`COLUMNS` 
where `table_name` = 'table-name' 
and `table_schema` = 'db-name';
Run Code Online (Sandbox Code Playgroud)


Kin*_*der 6

如果您想获取表格注释:

SELECT table_comment
FROM INFORMATION_SCHEMA.TABLES
WHERE table_name = 'my_table' and 
      table_schema = 'my_database'
Run Code Online (Sandbox Code Playgroud)

  • “information_schema”数据库中“tables”表的“table_comment”列保留**表**的注释,而不是列的注释;但也感谢您在这里指出它,因为它是相关的。 (2认同)