alter table sys_user add index idx_sys_user_nameagepos(name,age,pos);
以下是我们的检索语句:
select * from sys_user where name='小明' and age = 22 and pos ='java';
我们通过在检索语句前面加关键字 exlain,可以知道是否使用的索引
(1)explain select * from sys_user where name='小明' and age = 22 and pos ='java';
(2)explain select * from sys_user where name='小明' and age = 22 ;
(3)explain select * from sys_user where name='小明' and pos ='java';
(4)explain select * from sys_user where age = 22;
(5)explain select * from sys_user where pos ='java';
(6)explain select * from sys_user where age = 22 and pos ='java';
(9)explain select * from sys_user where name='小明' and age =22 and pos ='java';
(10)explain select name,age,pos from sys_user where name='小明' and age =22 and pos ='java';
(13)explain select * from sys_user where name like '%明%'
(14)explain select * from sys_user where name like '明%'
(15)explain select name,age,pos from sys_user where name like '%明%'