2015-01-09 56 views

回答

0

對於單臺使用:

show columns from tablename where `Key` is not null and `Key` != ''; 

對於整個架構/數據庫使用此:

select distinct 
    table_name, 
    index_name 
from information_schema.statistics 
where table_schema = 'your_database_name'; 

對於所有數據庫中刪除where子句。

show columns的文檔中描述。

Key字段指示該列是否被索引:

如果密鑰是空的,或者列沒有被索引或僅 被索引爲多列的次級柱,唯一索引。

+0

我想單個查詢來搜索數據庫中的所有表。 – user2323036

+0

@ user2323036:我更新了我的答案。 – Simulant

相關問題