Oracle-sql分页方法
C#因为Lambda表达式的存在,在代码里做分页显得非常简单,Skip后Take就可以了,所以之前也一直没试过在DB做分页。今天尝试在Oracle中做了次分页,发现效果也不错,速度挺快的,sql代码例子如下
SELECT * FROM ( SELECT ROWNUM NUM , T2.* FROM ( SELECT T1.* FROM TABLENAME T1 WHERE ROWNUM < 100 order by T1.CREATIONTIME ASC ) T2 WHERE ROWNUM < 100 ) T3 WHERE T3.NUM > 10 * (2 - 1) AND T3.NUM <= 10 * 2 -- 10为记录条数, 2为页码