2015-01-09 59 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

相关问题