您的位置:首页 > 数据库 > MySQL

mysql 查询表注释/字段注释

2016-06-15 16:17 344 查看
Select table_name 表名,TABLE_COMMENT 表注释 from INFORMATION_SCHEMA.TABLES Where table_schema = 'mstps' ##数据库名

AND table_name LIKE 'ms_staff';##表名

Select COLUMN_NAME 列名, COLUMN_TYPE 字段类型, COLUMN_COMMENT 字段注释

from INFORMATION_SCHEMA.COLUMNS

Where table_name = 'ms_staff'##表名

AND table_schema = 'mstps';##数据库名

##AND column_name LIKE 'c_name'##字段名
SELECT  COLUMN_NAME as '列名',COLUMN_COMMENT,DATA_TYPE as '字段类型' ,COLUMN_TYPE as '长度加类型' FROM information_schema.`COLUMNS` where TABLE_NAME like 'ms_staff';

select a.table_name , a.table_comment from (SELECT * FROM INFORMATION_SCHEMA.TABLES Where table_schema = 'mstps') a WHERE (a.TABLE_COMMENT) IN(

    Select b.TABLE_COMMENT FROM (SELECT * FROM INFORMATION_SCHEMA.TABLES Where table_schema = 'mstps') b GROUP BY (b.TABLE_COMMENT)

    HAVING COUNT(*)>1

);   ##查询单个数据库所有重复的数据

Select a.table_name dBname,a.TABLE_COMMENT sheetNotes from INFORMATION_SCHEMA.TABLES a Where table_schema = 'mstps' and a.TABLE_COMMENT LIKE CONCAT('%','购物车','%');##查询重复数据为'xx'的行

select * from xi a where (a.username) in  (select username from xi group by username  having count(*) > 1); ##查询重复数据
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: