oracle分页的两种方式

oracle中,做分页,一直用那种套路,先用order by排序,然后求出rownum,最后再根据papernumber和papersize来分页

select *
  from (select a.*, rownum rn
          from (select t.* from table t order by 某字段)a) b
 where b.rn between ((papernumber - 1)*papersize + 1)  and papernumber*papersize

 

今天又看到一个用row_number()函数进行分页的

select xx.*
  from (select t.*, row_number() over(order by 某字段) rn
          from table t) xx
 where rn between ((papernumber - 1)*papersize + 1)  and papernumber*papersize

 

你可能感兴趣的:(oracle,分页)