|
哪个快,哪个慢,在9i里,LZ的这个例子可以模拟一下,
create table tb_role(id number,parent_id number,rolename varchar2(30))
insert into tb_role(id,parent_id,rolename)values(1,0,'all')
insert into tb_role(id,parent_id,rolename)
select (rownum+2) as id,2 as parent_id,o_type as rolename from
(
select distinct(object_type) as o_type
from dba_objects where object_type
)
create table tb_user as
select a.object_id as id,b.id as role_id,a.object_name as login
from dba_objects a inner join
tb_role b on a.object_type=b.rolename
看看,然后再用LZ的语句,数据外大内小,用in 比exists大,呵呵,好象in更适合(由此得出结论: exits适合内小外大的查询,in适合内大外小的查询----这个结论刚好相反),在10G里,很多时候执行计划是一样的 |
|