oracle分頁查詢

2021-06-20 18:31:46 字數 1136 閱讀 4709

oracle分頁查詢

1、表 student

id  name  create_time

01  dong  2014-03-03 12:13:14

02  xiao  2014-03-04 12:13:14

03  wang  2014-03-05 12:13:14

2、基礎查詢語句

select id, name, create_time 

from student

where create_time > to_date('2014-03-02 12:13:14', 'yyyy-mm-dd hh24:mi:ss')

order by create_time

//這裡可以按你想要的規則篩選和排序

3、查詢總條數sql語句

select count(*) from (基礎查詢語句)
//查詢出總條數後,可以根據分頁大小,算出分頁數

4、分頁查詢sql語句(效率高)

select * from 

( select ta.*, rownum rn from (基礎查詢語句) ta

where rownum <= (page_num * one_page_size)

) tb

where tb.rn > ((page_num-1) * one_page_size )

//page_num從1開始

//此種方法查詢效率較高

5、分頁查詢sql語句(效率低)

select * from 

( select ta.*, rownum rn from (基礎查詢語句) ta

) tb

where tb.rn > ((page_num-1) * one_page_size )

and tb.rn <= (page_num * one_page_size)

//page_num從1開始

//此種方法查詢效率較低

ORACLE分頁查詢

單錶分頁 start num 起始行號 end num 截止行號 select t.from select s.rownum rn from table s where rownum end num t where rn start num 多表分頁 select from select temp....

Oracle分頁查詢

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

oracle 分頁查詢

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 r...