1. 要查询数据库 "food" 下所有表名以及表注释
/* 查询数据库 ‘food’ 所有表注释 */
SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE table_schema='food';
2. 要查询表字段的注释
/* 查询数据库 ‘food’ 下表 ‘batch’ 所有字段注释 */
SELECT COLUMN_NAME,column_comment FROM INFORMATION_SCHEMA.Columns WHERE table_name='batch' AND table_schema='food'
3. 一次性查询数据库 "food" 下表注释以及对应表字段注释
Select t.table_name 表名, t.column_name 字段名,t.column_type 字段属性, t.column_comment
from INFORMATION_SCHEMA.COLUMNS t
where table_schema = 'food'
4、查询某库所有表名、字段名等属性
Select t.table_name 表名,t2.TABLE_COMMENT 表注释, t.column_name 字段名,t.column_type 字段属性, t.column_comment
from INFORMATION_SCHEMA.COLUMNS t,information_schema.TABLES t2
where t.table_schema = 'food'
and t2.TABLE_NAME = t.table_name
and t2.TABLE_SCHEMA = t.table_schema