Oracle半连接学习总结(三)

2014-11-24 13:31:22 · 作者: · 浏览: 5
48 0 0

Execute 1 0.00 0.00 0 0 0 0

Fetch 1 0.15 0.48 1796 1799 0 6

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

total 3 0.15 0.49 1796 1847 0 6

Misses in library cacheduring parse: 1

Optimizer mode: ALL_ROWS

Parsing user id: 92

Rows Row Source Operation

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

6 HASH JOIN RIGHT SEMI (cr=1799 pr=1796 pw=1796time=10 us cost=535 size=13 card=1)

6 COLLECTION ITERATOR PICKLER FETCHSTR_TO_TABLE (cr=0 pr=0 pw=0 time=2 us)

500000 TABLE ACCESS FULL TABLE_1 (cr=1799 pr=1796pw=1796 time=7559 us cost=503 size=5500000 card=500000)

some any all

在oracle数据库的比较运算符中ANY SOME与all

any 与some是同样的意义,通常用在不等的比较运算中,当使用”=”的时候,则就是半连接

select ename, sal, comm from emp where sal < any( select commfrom emp );

select ename, sal, comm from emp where sal < ( select max(distinctcomm) from emp)

在业务含义上是相当的,但是oracle提供了不同的执行计划

select ename, sal, comm from emp where sal = some( select commfrom emp );

select ename, sal, comm from emp where sal in ( select comm from emp );

在商业含义上是一样的,在多数情况下oracle提供了半连接的执行计划

select ename, sal, comm from emp where sal > any( select commfrom emp);

select ename, sal, comm from emp where sal > ( select min(distinctcomm) from emp)

在业务含义上是相当的,但是oracle提供了不同的执行计划

some与any可以互换。而all正好与some all的意思相反

select ename, sal, comm from emp where sal < all( select commfrom emp );

select ename, sal, comm from emp where sal < ( select min(distinctcomm) from emp)

在商业含义上是一样的.

与member一样,some any all在过程中

declare

i integer;

type type_num is table ofnumber;

c_num type_num :=type_num(1,2,3,4,5);

begin

select count(b) into i fromtable_1

where a = some(c_num);

dbms_output.put_line(i);

end;

第8 行出现错误:

ORA-06550: 第8 行, 第19 列:

PLS-00642: 在SQL 语句中不允许使用本地收集类型

原创文章,如果转载,请标注作者:田文 CSDN地址:http://blog.csdn.net/tiwen818