Oracle的分页查询实现,采用ROWNUM。
格式1(推荐)
SELECT * FROM
(
SELECT temp.*, ROWNUM RN
FROM (SELECT * FROM 表名) temp
WHERE ROWNUM <=end (page*pagesize)
)
WHERE RN >=start (page-1*pagesize+1)
格式2
SELECT * FROM
(
SELECT temp.*, ROWNUM RN
FROM (SELECT * FROM TABLE_NAME) temp
)
WHERE RN BETWEEN start (page-1*pagesize+1) AND end (page*pagesize)