`

oracle 语句分页优化

阅读更多

一种常用的方法 rownum方法

   select *
  from (select x1.*, rownum r
          from (select x.* from appsys_objects x order by id) x1
         where rownum < 10)
 where r > 5

 

二种rowid 方法

   select *
  from (select rid, r
          from (select rid, rownum r
                  from (select rowid rid from appsys_objects x order by id)
                 where rownum < 10)
         where r > 5) t,
       appsys_objects t1
 where t.rid = t1.rowid

 

据说第二种比第一种在数据量大时、取中间段时相对要快。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics