第五章:索引的使用-复合索引前导列特性

直接学习:https://edu.csdn.net/course/play/27328/362533
复合索引前导列特性:
#1、在mysql中如果创建了复合索引(name,salary,dept),就相当于创建了(name,salary,dept),(name,salary),(name)三个索引,这被称为复合索引前导特性。
#2、示例代码如下:

show index from employee\G;
explain select * from employee where name= '柳锋'\G;
create index index_name_salary_dept on employee(name,salary,dept);
explain select * from employee where name= '柳锋'\G;
explain select * from employee where salary= 8800\G;
explain select * from employee where dept= '部门A'\G;

explain select * from employee where name= '柳锋'and salary=8800\G;
explain select * from employee where name= '柳锋'and dept='部门A'\G;
发布了107 篇原创文章 · 获赞 6 · 访问量 968

猜你喜欢

转载自blog.csdn.net/weixin_43597208/article/details/105484460
今日推荐