1. 程式人生 > >oracle------分頁操作

oracle------分頁操作

顯示前五行的資料:

select * from (
select rownum rn,e.empno,e.ename,e.job,e.hiredate,e.sal
from emp e
where rownum <= 5) e1
where e1.rn > 0;


顯示6-10行的資料:

select * from (
select rownum rn,e.empno,e.ename,e.job,e.hiredate,e.sal
from emp e
where rownum <= 10) e1
where e1.rn > 5;


fetch的語法以及作用:

取得前五行資料:

select * from emp order by sal desc fetch first 5 row only;


取得4-5行的資料:

select * from emp 
order by sal desc 
offset 3 rows fetch next 2 rows only;