MySQL查询表字段注释
AlightYoung 6/5/2020 MySQL
# SQL语句
/* 查询数据库 ‘mammothcode’ 所有表注释 */
SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE table_schema='mammothcode';
1
2
2
/* 查询数据库 ‘mammothcode’ 下表 ‘t_adminuser’ 所有字段注释 */
SELECT COLUMN_NAME,column_comment FROM INFORMATION_SCHEMA.Columns WHERE table_name='t_adminuser' AND table_schema='mammothcode'
1
2
2
/* 一次性查询数据库 "mammothcode" 下表注释以及对应表字段注释*/
SELECT t.TABLE_NAME,t.TABLE_COMMENT,c.COLUMN_NAME,c.COLUMN_TYPE,c.COLUMN_COMMENT FROM information_schema.TABLES t,INFORMATION_SCHEMA.Columns c WHERE c.TABLE_NAME=t.TABLE_NAME AND t.`TABLE_SCHEMA`='mammothcode'
1
2
2