- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
2#
发表于 2012-4-16 22:37:20
1 . 不是 birthday <= all 只是一个 谓词predicate , birthday 是一个谓词列
birthday <= all( 元素A,元素B,元素c) 是列表(list)形式的 ALL 谓词
birthday <=all (select * from .....) 是子查询(subquery)形式的ALL谓词
2.
ALL
The ALL comparison condition is used to compare a value to a list or subquery. It must be preceded by =, !=, >, <, <=, >= and followed by a list or subquery.
When the ALL condition is followed by a list, the optimizer expands the initial condition to all elements of the list and strings them together with AND operators, as shown below.
我们来看一个例子
SQL> oradebug setmypid;
Statement processed.
SQL> oradebug event 10053 trace name context forever,level 1;
Statement processed.
select empno, sal
FROM scott.emp
WHERE sal <= all (SELECT e2.sal FROM scott.emp e2 WHERE e2.deptno = 20);
EMPNO SAL
---------- ----------
7369 800
优化器会把以上<=ALL的语句 装换成下面的 NOT EXISTS的形式
SELECT /*+ */ "SYS_ALIAS_1"."EMPNO" "EMPNO","SYS_ALIAS_1"."SAL" "SAL" FROM
"SCOTT"."EMP" "SYS_ALIAS_1"
WHERE NOT EXISTS (SELECT /*+ */ 0 FROM "SCOTT
"."EMP" "E2" WHERE "E2"."DEPTNO"=20 AND LNNVL("E2"."SAL">="SYS_ALIAS_1"."SAL")) |
|