oracle sql 分页

oracle实现分页时,需要引入一个rownum的函数

方法一:使用rownum嵌套查询

select * from ( select e.* , rownum as rn from emp e where rownum  <= 10 ) t where t.rn >= 1;

方法二:方法一的另一种写法

select * from ( select e.* , rownum as rn from emp e) t where t.rn >= 1 and t.rn <=10;

方法三:使用分析函数row_number

select * from ( select t.* , row_number() over(order by ename) as rn from emp t ) where rn>=1 and rn<=10

扫描二维码关注公众号,回复: 1156248 查看本文章

方法四:使用rowid

select * from emp where rowid in ( select rid from (select rowid as rid, rownum as id from emp t where rownum < 15) where id >= 10 );

方法五:使用minus

select * from emp where rownum <= 15 minus select * from emp where rownum < 10;

猜你喜欢

转载自tzz6.iteye.com/blog/2175447