乙個非常好的ORACLE的分頁SQL語句

2021-04-01 08:02:49 字數 844 閱讀 7275

select * from (select my_table.*, rownum as my_rownum from ( select yhbh, yhmc from yysf_tb_yonghxx order by yhbh) my_table where rownum <20 ) where my_rownum>=10

其它幾種分頁實現:

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多條記錄

個人感覺1的效率最好,3次之,2最差

Oracle 的乙個非常好的觸發器例子

create orreplace trigger test trigger after insert orupdate of sal or delete onemp foreach row begin case when inserting then 當事件為insert時,inserting為tr...

乙個講的非常好的快速排序

講的非常好,反正我是看懂了 package com.shadow.util 快速排序的乙個實現 author shadow public class myquicksort 一次查詢後,將基準數歸位 arr left arr i arr i pivot 繼續處理左邊的,這裡是乙個遞迴的過程 quic...

tinyxml非常好的例項

這個例子對於只想簡單使用xml的使用者來說,非常有學習價值。完整程式 相信具有基本c 知識的人可以明白的 xml檔案內容 xml version 1.0 encoding gb2312 standalone yes resumes num 2 resume name 裕作 gender 男 gend...