聚集索引:可以理解为表的主键,可以通过主键拿表中完整的一行数据
辅助索引:单列索引与联合索引
联合索引最左原则:比如创建(a,b,c)联合索引,相当于创建了a,ab,abc这三个索引,在使用联合索引进行查询的时候必须包含最左列
查看表的索引:`desc test; show index from test;`
创建索引示例:
随建表语句创建索引:`create table test(id int primary key auto_increment, name varchar(10), age int, index idx_name(name))`
给表增加索引:`alter table test add index idx_age(age); alter table test add index idx_name_age(name,age); `
删除索引:`alter table test drop index idx_age;`