如何通过系统表查看表的索引和注释?
warning:
这篇文章距离上次修改已过1648天,其中的内容可能已经有所变动。
查看某一个库下某一张表的索引
SELECT DISTINCT lower(index_name) index_name,lower(index_type) type FROM information_schema.statistics
WHERE table_schema = 'employees' AND table_name = 'employees';
查看某一个库下某一张表的某一个索引
SELECT lower(column_name) column_name,seq_in_index column_position FROM information_schema.statistics
WHERE table_schema = 'employees' AND table_name = 'employees' AND index_name = 'primary';
查看某一个库下某一个表的注释
SELECT table_comment comments FROM information_schema.TABLES
WHERE table_schema = 'employees' AND table_name = 'employees';
查看某一个库下某一个表的列的注释
SELECT lower(column_name) column_name,column_comment comments
FROM COLUMNS WHERE table_schema = 'employees' AND table_name = 'employees';