/*[startIndex,endIndex]*/
/*no.1*/
/*
[1,20],0.233s,0.141s,0.157s,0.109s,0.188s
[2001,2020],0.312s,0.172s,0.125s,0.188s,0.124s
[2001,2100],0.438s,0.547s,0.391s,0.453s,0.406s
[5001,5030],0.251s,0.202s,0.282s,0.172s,0.219s
[6001,6050],0.344s,0.313s,0.297s,0.328s,0.281s
*/
select * from table_name where id in
(
select id from (select id,rownum r from table_name where rownum<=endIndex) where r>startIndex-1
)
order by id
/*no.2*/
/*
[1,20],0.14s,0.126s,0.14s,0.267s,0.125s
[2001,2020],0.124s,0.141s,0.188s,0.124s,0.249s
[2001,2100],0.407s,0.391s,0.407s,0.593s,0.391s
[5001,5030],0.265s,0.249s,0.235s,0.203s,0.235s
[6001,6050],0.344s,0.297s,0.281s,0.266s,0.36s,0.312s
*/
select * from table_name where id in
(
select id from table_name where rownum<=endIndex
minus
select id from table_name where rownum<startIndex
)
order by id
分页原理是:
Oracle有个rowid,还有个rownum.
先把标识列选出来,若自己有标识列就可以用自己的标识列;然后再把所有的记录选出来。