原网址:http://blog.sina.com.cn/s/blog_7e4ac8b50100vcwv.html
SQL 条件字段(Where 部分)的分析和执行顺序[ 右——>左 ] 实验一:证明了SQL的语法分析是从右到左的 下面的试验在9i和10G都可以得到相同的结果: 第1条语句执行不会出错,第2条语句会提示除数不能为零。 1.Select 'ok' From Dual Where 1 / 0 = 1 And 1 = 2; 2.Select 'ok' From Dual Where 1 = 2 And 1 / 0 = 1; 证明了SQL的语法分析是从右到左的。
实验二:证明了SQL条件的执行是从右到左的 drop table temp; create table temp( t1 varchar2(10),t2 varchar2(10)); insert into temp values('zm','abcde'); insert into temp values('sz','1'); insert into temp values('sz','2'); commit; 1. select * from temp where to_number(t2)>1 and t1='sz'; 2. select * from temp where t1='sz' and to_number(t2)>1; 在9i上执行,第1条语句执行不会出错,第2条语句会提示“无效的数字” 在10G上执行,两条语句都不会出错。 说明:9i上,SQL条件的执行确实是从右到左的,但是10G做了什么调整呢?
还有几个网址:
http://www.52php.cn/article/p-pfeqmotn-bdk.html
要提高SQL查询效率where语句条件的先后次序应如何写
SQL中的where的条件的执行顺序 http://bbs.csdn.net/topics/350234598 Oracle 执行计划(Explain Plan) 说明 http://blog.chinaunix.net/uid-21187846-id-3022916.html
未完待续。 (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|