天天看點

mysql找到所有索引

SELECT a.TABLE_SCHEMA,

a.TABLE_NAME,

a.index_name,

GROUP_CONCAT(column_name ORDER BY seq_in_index) AS `Columns`

FROM information_schema.statistics a

GROUP BY a.TABLE_SCHEMA,a.TABLE_NAME,a.index_name

--查找每個列對應的索引:

select a.TABLE_SCHEMA,a.TABLE_NAME,a.column_name, a.index_name,a.seq_in_index,b.Columns from information_schema.statistics a left join

(

) b on a.TABLE_SCHEMA=b.TABLE_SCHEMA and a.TABLE_NAME=b.TABLE_NAME and a.index_name=b.index_name