Mysql 获取表的comment 字段

 1 -- 查看获取表内字段注释:
 2 show full columns from tablename;
 3 -- 或是 
 4 show full fields from tablename;
 5 -- 或是,在元数据的表里面看
 6 Select COLUMN_NAME 列名, DATA_TYPE 字段类型, COLUMN_COMMENT 字段注释
 7 from INFORMATION_SCHEMA.COLUMNS
 8 Where table_name = 'companies'##表名
 9 AND table_schema = 'testhuicard'##数据库名
10 AND column_name LIKE 'c_name'##字段名
11 
12 
13 -- 2-1查看表注释的方法:
14 show  create  table  tablename;
15 
16 -- 2-2获取整个数据库的所有表信息(包含表名,表注释,表类型等等):
17 SELECT table_name, table_type, engine
18 FROM information_schema.tables
19 WHERE table_schema = 'db5' //table_schema是数据库名
20 ORDER BY table_name DESC;
21 -- 该语句请求按逆向字母顺序列出数据库db5中的所有表,但仅显示三种信息:表名,表类型,以及表引擎。
22 -- INFORMATION_SCHEMA是信息数据库,其中保存着关于MySQL服务器所维护的所有其他数据库的信息.
23 
24 SELECT TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES  WHERE TABLE_NAME = 'sh_goods' AND TABLE_SCHEMA = 'sh_shop';//获取sh_shop 数据库中 sh_goods 表 的注释。
25 
26 -- 2-3获取表注释或是
27 -- 或者使用:
28 show table status;
29 --  Comment 就是表注释。
30 
31 
32 
33 -- 拓展:
34 
35 -- 修改表的注释:
36 alter table test1 comment '修改后的表的注释';
37 
38 -- 修改字段的注释:
39 alter table test1 modify column field_name int comment '修改后的字段注释';  
原文地址:https://www.cnblogs.com/sumlen/p/11101315.html