实现方法一:
通过INFORMATION_SCHEMA
系统数据库中的TABLES
表和TABLE_COMMENT
字段,可以查询到所有表的注释
SELECT table_name, table_comment
FROM information_schema.tables
WHERE table_schema = 'your_database_name';
实现方法二:
通过SHOW TABLE STATUS
语句查询到所有表的注释。
SHOW TABLE STATUS
FROM your_database_name;
实现方法三:
通过INFORMATION_SCHEMA.TABLES
和INFORMATION_SCHEMA.COLUMNS
系统表进行关联查询,可以查询到所有表和字段的注释。
SELECT t.table_name, t.table_comment, c.column_name, c.column_comment
FROM information_schema.tables AS t
JOIN information_schema.columns AS c ON t.table_name = c.table_name
WHERE t.table_schema = 'your_database_name';