用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上的索引
(责任编辑:卢兆林)
数据挖掘实验室
Create By Any-Extract(WL-AE) 数据挖掘交友