使用索引的误区之二:使用了 和 != 操作符,导致查询不使用索引[5]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 lunar2000 的 blog

 

 

再做一个试验:

sql> desc dept

name   type         nullable default comments

------ ------------ -------- ------- --------

deptno number(2)    y

dname  varchar2(14) y

loc    varchar2(13) y

 

创建一个单键索引:

sql> create index dept_id1 on dept(dname);

 

index created

 

如果使用"<>",则查询不使用索引:

select deptno from dept where dname <> 'developer';

 

plan_table_output

--------------------------------------------------------------------------------

--------------------------------------------------------------------

本文关键:使用索引的误区之二:使用了 和 != 操作符,导致查询不使用索引
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top