北方站长站
客服热线:0632-5117766

"Select"语句究竟是如何来使用索引的?

[2008-01-31 04:58:00] 作者:楠惜梦 来源:北方站长站

Tags:使用 索引 如何 究竟 语句 from select where t1 hiredate

  

用Select语句使用索引:

select * from t1 ;

--不能用索引,全表扫描

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上的索引

(责任编辑:卢兆林)

 

News

 

info

 

down

出售手机裁听器,手机跟踪定位系统    企业网站,网城,购物网,都市导购,校园网    网上书店系统    上海电信机房服务器托管,双线主机托管    美女图片馆    15G 高清晰图片资源 无水印    室内装潢材料新产品杰威尔艺术漆    收一万ip的美女图片    大量收购个人网址导航网站    出售网址站PR=4alexa=119,764    

下一篇链接:一条SQL语句变得巨慢的原因及其解决方法

上一篇链接:用一个实例讲解GROUP BY CEIL的使用方法

评论】 【打印】 【加入收藏】 【关闭→论坛 →博客 →数据中心

 共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面