Oracle 分頁的三種情況

來源:互聯網
上載者:User

Oralce 的分頁一共有三種

1. rownum

select *  from emp

2. 顯示rownum[Oracle 分配的]

select a1.* ,rownum rn from (select * from emp) a1;

3.幾個查詢的變化

a.指定查詢列只需修改最裡層的子查詢就可以了

b.排序也是只需要修改最裡面的就可以了

----------------------------------------------------------

1.按ROWID來分

select * from t-xiaoxi where rowid in (select rid from

(select rownum rn,rid from (select rowid, rid,cid from

t_xiaoxi order by cid desc) where rownum<10000)where

rn>9980) order by cid desc;

執行時間為0.03秒

2.按分析函數來分

select * from (select t.* ,row_number() over(order by cid

desc ) rk from t_xiaoxi t ) where rk<10000 and rk>9980;

執行時間為1.01 秒

3.按ROWNUM 來分

select * from (select t.* ,rownum rn from (select * from

t_xiaoxi order by cid desc ) t where rownum<10000) where

rn>9980 ;

執行時間為0.1秒

其中—t_xiaoxi 為表名,cid為表的關鍵字段,取按CId降序排序

後的第9981-9999條記錄,t_xiaoxi 表中有70000多條記錄

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.