rownum是Oracle数据库中的一个特有关键字,返回的是一个数字代表记录的行号。这篇文章主要介绍了oracle 使用rownum的二种分页方式,需要的朋友可以参考下
第一种,直接使用起止限定数:
SELECT * FROM (SELECT t.,ROWNUM r FROM TABLE t WHERE ROWNUM <= pagepageSize) WHERE r >= ((page - 1) * pageSize + 1)
//第一种分页
select * from (select ROWNUM r, s.* from PDD.ORDER_CASH s WHERE ROWNUM <=20) where r>= 1
select * from (select ROWNUM r, s.* from PDD.ORDER_CASH s WHERE ROWNUM <= 40) where r>=21
第二种:使用BETWEEN:
SELECT * FROM (SELECT t.,ROWNUM r FROM TABLE t ) WHERE r BETWEEN ((page - 1) * pageSize + 1) AND (pagepageSize)
//第二种分页
select * from (select ROWNUM r, s.* from PDD.ORDER_CASH s ) where r BETWEEN 1 AND 20
select * from (select ROWNUM r, s.* from PDD.ORDER_CASH s ) where r BETWEEN 21 AND 40