Oracle之分頁查詢

2021-07-11 14:20:36 字數 871 閱讀 5633

分頁查詢:在資料量大的情況下,返回指定資料段資料集合,即從第m條 到 第n條 資料集合。

分頁查詢一般只需傳入兩個引數(起始記錄數m、終止記錄數n)。

方式1:

select * from

(select rownum as rowno, t.*

from t_table t

where 1=1

and rownum < 21

) tt

where tt.rowno > 10

方式2:

select * from

(select rownum as rowno, t.*

from t_table t

where 1=1

) where rn >1 and rn <11

方式3:引用between……and函式

select * from

(select rownum as rowno, t.*

from t_table t

where 1=1

) where rn between 1 and 10

本示例查詢的是(9,21)的10條記錄,原本使用「 <= 20 」結合「 >=10 」也能查詢出10條記錄,但不推薦使用,因為「 <= 」 和 「 >= 」都進行了兩次查詢,而本例查詢語句一次即可查詢出來。 

同時,在where 1=1 後面,and前面,可以加入其它限制條件用and接入,實現複雜查詢。

Oracle之分頁查詢

oracle的分頁查詢語句基本上可以按照本文給出的格式來進行套用。分頁查詢格式 select from select a.rownum rn from select from table name a where rownum 40 where rn 21其中最內層的查詢select from ta...

Oracle之分頁查詢

oracle的分頁查詢語句基本上可以按照本文給出的格式來進行套用。分頁查詢格式 view code select from select a.rownum rn from select from table name a where rownum 40 where rn 21其中最內層的查詢sele...

Oracle之分頁查詢

oracle的分頁查詢語句基本上可以按照本文給出的格式來進行套用。分頁查詢格式 select from select a.rownum rn from select from table name a where rownum 40 where rn 21 其中最內層的查詢select from t...