一、mysql聚簇索引查询
1、如何查询表的索引基本情况?
select * from INFORMATION_SCHEMA.STATISTICS where table_name='数据库表名' and table_schema ='数据库名';
2、查询表Id
select TABLE_ID,NAME from INFORMATION_SCHEMA.INNODB_TABLES where NAME like '%表名%';
3、查询索引类型
table_id是第2步的查询结果
select * from INFORMATION_SCHEMA.INNODB_INDEXES where TABLE_ID='1062';
这个输出关键看TYPE字段,TYPE字段官网解析如下:
A numeric identifiersignifying the kind of index. 0 = Secondary Index, 1 =Clustered Index,2 = Unique Index, 3 = PrimaryIndex, 32 = Full-text Index, 64 = Spatial Index, 128 = A secondary indexthat includes agenerated virtual column
TYPE为0便是辅助索引,也是非聚簇索引,1是聚簇索引,2是唯一索引,3是主键索引,32是全文索引
|