通过系统表查询表及字段内容
作者:互联网
通过系统表查询表及字段内容
查询数据库中所有表
SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE table_schema=‘abc’;
查询数据库中特定表的所有字段及注释
SELECT distinct t.TABLE_NAME,t.TABLE_COMMENT,c.ordinal_position,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=‘abc’ and t.Table_name = ‘user’
order by t.TABLE_NAME,c.ordinal_position;
查询数据库中所有表的所有字段及注释
SELECT t.TABLE_NAME,t.TABLE_COMMENT,c.ordinal_position,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=‘abc’
order by t.TABLE_NAME,c.ordinal_position;
标签:COMMENT,NAME,COLUMN,查询,表及,内容,查询数据库,TABLE,schema 来源: https://blog.csdn.net/log2003/article/details/110506444