Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
1. To query all database table names and table under Notes
/* 查询数据库 ‘mammothcode’ 所有表注释 */
SELECT TABLE_NAME,TABLE_COMMENT
FROM information_schema.TABLES
WHERE table_schema='mammothcode';
2. To query the comment field of the table
/* 查询数据库 ‘mammothcode’ 下表 ‘t_adminuser’ 所有字段注释 */
SELECT COLUMN_NAME,column_comment
FROM INFORMATION_SCHEMA.Columns
WHERE table_name='t_adminuser' AND table_schema='mammothcode'
3. The one-time query the database table and the correspondence table Field Comment Notes
/* 查询数据库 "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'