oracle分頁 使用rownum 偽列

2021-06-02 09:50:00 字數 1530 閱讀 3868

connected to oracle database 10g enterprise edition release 10.2.0.1.0

connected as tudou

sql> select * from temp1;

name                age

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

土土                22

z壯                 23

z                   25

a                   28

奇才                29

才子、              12

二飄落              14

脾用                18

fdffs               18

ppppp               18

大規模              13

11 rows selected

sql> select * from temp1 where rownum<4;

name                age

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

土土                22

z壯                 23

z                   25

sql> select * from (select * from temp1 where rownum<=3*4) where age not in(select age from temp1 where rownum<=(3-1)*4);

name                age

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

大規模              13

sql> select * from (select * from temp1 where rownum<=2*4) where age not in(select age from temp1 where rownum<=(2-1)*4);

name                age

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

奇才                29

才子、              12

二飄落              14

脾用                18

sql>

oracle中使用rownum[偽列]進行分頁:

rownum分頁

select * from(select m.*,rownum rn from(select * from tb)m) where rn between 11 and 20

select * from(select m.*,rownum rn from(select * from tb)m where rownum<=20) where rn >=20

第二種演算法效率比第一種高...

Oracle中使用rownum分頁

oracle的常用分頁就是rownum,在公司中也是使用rownum分頁。在oracle中分頁和mysql中不一樣,在mysql中由limit x,y這種形式分頁,而在oracle中常用分頁就是使用rownum分頁,相當於限定行數,從0行到多少行。rownum分頁必須從rownum 0開始,然後ro...

使用oracle儲存過程分頁

1.首先在oracle中建儲存過程,儲存過程名庫 procedure prc query create or replace procedure prc query p tablename in varchar2,表名 p strwhere in varchar2,查詢條件 p ordercolum...

oracle分頁和mysql分頁

mysql 分頁 查前5 資料 select from table name limit 0,5 select from table name limit 5 limit關鍵字的用法 limit offset,rows offset指定要返回的第一行的偏移量,rows第二個指定返回行的最大數目。初始...