mysql中,创建索引的目的其实就是加速对表的查询,几种常用方法如下:
1.使用create index创建索引:
语法:create index 索引名 on 表名(字段名)
下面索引将会提高tbl_user表的username字段的查询速度:
create index username_index on tbl_user(username);
同时,也可对多列创建索引:
语法:create index 索引名 on 表名(字段名1,字段名2)
2.删除索引:
语法:drop index 索引名 on 表名:
drop index username_index on tbl_user;