mysql数据库中给表添加index

一、添加index

1、alter table tableName add index indexName(conlum1,conlum2)

2、create index indexName on tableName(conlum1,conlum2)

二、删除index

1、alter table tableName drop index indexName;

2、drop index indexName on tableName;

三、查询table上的index

 show index from tableName

 

注:当列的数据类型为varchar且数据为数字的时候,谨记保持数据类型一致;在select前添加explain查看查询信息

EXPLAIN select * from xln_source where gender = 9 and age = 3

key表示使用的索引的名称

 

    

 

posted @ 2017-04-28 14:15  郭大侠227  阅读(1373)  评论(0)    收藏  举报