2016-07-25 78 views
1

我有一個表,其索引由表中的三列組成。在information_schema中查找多列索引

有沒有一種方法可以在information_schema中找到它,還是隻會顯示三個單獨的索引?

答發現:

SELECT table_name AS `Table`,  index_name AS `Index`,  GROUP_CONCAT(column_name ORDER BY seq_in_index) AS `Columns` FROM information_schema.statistics WHERE table_schema = 'db' and table_name='tbl' GROUP BY 1,2; 
+1

你有沒有試着用搜索引擎:http://blog.9minutesnooze.com/mysql-information -schema-indexes /? –

+0

謝謝,我發現我在找那個鏈接。 – user3299633

+1

請在下面的「答案」部分發布您的答案 - 它被接受,所以回答自己的問題的做法。 –

回答

0

感謝您的Radek Postolowicz的轉向我朝着正確的方向:

SELECT table_name AS `Table`,  index_name AS `Index`,  GROUP_CONCAT(column_name ORDER BY seq_in_index) AS `Columns` FROM information_schema.statistics WHERE table_schema = 'db' and table_name='tbl' GROUP BY 1,2;