显示来自 Mysql 表的字段的注释

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5404051/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:15:10  来源:igfitidea点击:

Show Comment of Fields FROM Mysql Table

mysql

提问by Starx

SHOW COLUMNS FROM <tablename>gives all the information of the columns in a table, except Comments.

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

How to extract Commentsinformation? I know the way to extract the information from INFORMATION SCHEMA, but how to combine the result in a single result set?

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

回答by Nicola Cossu

You can use the query

您可以使用查询

SHOW FULL COLUMNS FROM <tablename>

If you don't want to use information_schema.

如果您不想使用information_schema.

回答by KingRider

Example:

例子:

SELECT table_comment
FROM INFORMATION_SCHEMA.TABLES
WHERE table_name = 'my_table' and 
      table_schema = 'my_database'

回答by shenyan

select `column_name`, `column_type`, `column_default`, `column_comment`
from `information_schema`.`COLUMNS` 
where `table_name` = 'table-name' 
and `table_schema` = 'db-name';