oracle自定义的三种分页

来源:互联网 发布:网络使人疏远的例子 编辑:程序博客网 时间:2024/06/06 01:12

以前用oracle 分页都不是自己写的,所以今天专门学了下怎么用oracle分页 其实也是参考别人的语句,自己按照学习写
--rowid分页
select * from (select rownum rn,t2.* from (select t1.*,rowid rid from temp t1) t2 where rownum <= 1000) where rn >=800;


--rownum分页


select * from (select rownum rn,t1.* from (select * from student) t1 where rownum<=10) where rn >= 5;


--row_number函数分页
select  *  from
(select  t.* ,row_number() over (order  by xh  desc ) rk   from  student  t)
 where  rk <=10  and  rk  >=5;


--三种方式比较
select rownum rn,t1.* from (select * from temp) t1 where rownum<=1000 minus select rownum rn,t1.* from (select * from temp) t1 where rownum<=800;
set timing on;
select * from (select rownum rn,t1.* from (select * from temp) t1 where rownum<=1000) where rn >= 800;
select * from (select rownum rn,t2.* from (select t1.*,rowid rid from temp t1) t2 where rownum <= 1000) where rn >=800;


我是参考别人的语句,希望可以帮到大家。


0 0