请问oracle中连接查询并分页,以下写法正确的是什么

来源:百度知道 编辑:UC知道 时间:2024/05/07 16:03:28
select emp.*,dept.* from emp,dept,
(
select newrowid
from (select res.*, rownum rownum_
from (select t.rowid newrowid from emp t) res
where rownum <= 6)
where rownum_ >= 4
) tt
where emp.rowid = tt.newrowid
and emp.deptno = dept.deptno
-----------------------------------------------------
select emp.*,dept.* from emp,dept,
(
select rowid1,rowid2
from (select res.*, rownum rownum_
from (select emp.rowid rowid1,dept.rowid rowid2 from emp,dept where emp.deptno = dept.deptno) res
where rownum <= 6)
where rownum_ >= 4
) tt
where emp.rowid = tt.rowid1
and dept.rowid = tt.rowid2
and emp.deptno = dept.deptno
---------

实际效果要看Oracle 优化以后的
不过,从理论上来说,2好一些,因为提前做了关联取的集合较小
Oracle是建议先将小集合进行关联的,然后在针对rowid进行排序

dsafff