用Select语句使用索引:
--不能用索引,全表扫描
select * from t1 where age > 20; |
--能用age上的索引
select * from t1 where name like '李%'; |
--能用上name上的索引
select * from t1 where xh <45; |
--能用上xh上的索引;
select * from t1 where age > 20; |
--能用索引
select * from t1 where age+10>30; |
--不能用age上的索引
规则1:索引的字段不能参与运算
select * from t1 where substr(name,1,1)='李'; |
--不能用索引
规则2:索引的字段上不能使用函数
select * from t1 where name like '李%'; |
--能用索引
查询emp表中hiredate在1982年10月到1999年9月的员工??
select * from emp where to_char(hiredate,'yyyymm') >= '198210' and to_char(hiredate,'yyyymm') <='199909';create index ind_hiredate on emp(hiredate); |
--用不上hiredate上的索引
select * from emp where hiredate <= to_date('19990901','yyyymmdd') and hiredate >= to_date('19821001','yyyymmdd'); |
--能用上hiredate上的索引
(责任编辑:卢兆林)
共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面