日期:2014-05-16  浏览次数:20425 次

关于oralce分页的2种写法
1. 
SELECT *
    FROM (SELECT T.*, ROWNUM ROWNUM_
            FROM (SELECT A.*
                    FROM table A
                   ORDER BY A.FieldName DESC) T
           WHERE ROWNUM < endNum) T
   WHERE T.ROWNUM_ > startNum

2. 
SELECT X.*
  FROM (SELECT ROW_NUMBER() OVER(ORDER BY FieldName DESC) AS ROW_NO,
               A.*
          FROM table A) X
 WHERE X.ROW_NO <= 41
   AND X.ROW_NO >= 21;



  • 据说1到了1W条数据后每页都慢,
  • 据说2到了1W条数据后最后一页慢