oracle 分页sql模板

select /* + ordered use_nl(tt,t) */   
 t.*   
  from (select *   
          from (select rownum rn, a.rid   
                  from (select rowid rid   
                          from tableName   
                         where condition) a   
                 where rownum <= #endRow#)   
         where rn >= #startRow#) tt,   
       tableName t   
 where tt.rid = t.rowid


另外一种简单的分页模板
select *
  from (select a.*, rownum rn
          from (select t.*
                  from tablename t
                 where condition) a
         where rownum <= #endRow#)
 where rn >= #startRow#

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