1. 程式人生 > >orcale 資料庫分頁

orcale 資料庫分頁

 orcale 資料庫分頁查詢 SQL語句寫法:推薦第三種

--分頁查詢一
select *
  from (select a1.*, rownum rn
          from (select * 資料庫表名) a1
         where rownum <= 5)
 where rn >= 1;

--分頁查詢二
select a1.*
  from (select 資料庫表名.*, rownum rn from 資料庫表名 where rownum <= 5) a1
 where rn >= 1;

--分頁查詢三
select a1.*
  from (select 資料庫表名.*, rownum rn from 資料庫表名) a1
 where rn between 1 and 5;
一:
select *
  from (select c.status
          from c_claim_tasks c
         where c.stage = '007')
 where rownum <= 5
   and rownum >= 1;


二:
select *
  from (select c.status
          from c_claim_tasks c
         where stage = '007')
 where rownum between 1 and 5