All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
SQL语句在什么情况下使用全表扫描-_[SQL Server教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/2/3 6:40:34 Browse times: 454 Comment times: 0

SQL语句在什么情况下使用全表扫描-_[SQL Server教程]


Head photo

Go homepage
Upload pictures
Write articles

SQL语句在什么情况下使用全表扫描?_[SQL Server教程]

问:SQL语句在什么情况下使用全表扫描?

答:

1:对返回的行无任何限定条件,即没有where 字句

2:对数据表与任何索引主列相对应的行限定条件,例如:在City-State-Zip列创建了三列复合索引,那么仅对State有列限定条件不能使用这个索引,因为State不是索引的主列。

3:对索引的主列有限定条件,但是条件在表达式里使用,例如:在City上有索引,但是若使用表达式,如:

where upper(city)='TokYo' 或
City || 'X' like 'TOKYO%',

那么不会使用索引。

4:对索引的主列有限定条件,但是条件或者是Null或者是不相等。例如:在City上有索引,但是若使用表达式,如:

where City is null,where City is
not null,Where city!='TOKYO'.

5: 对索引的主列有限定条件,但是条件使用like操作以及值以‘%’开始或者值是一个赋值变量。例如:

where City like '%YOK%'
where City like: City_bind_Variable xl_rao





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.