对于rownum来说它是oracle系统顺序分配为从查询返回的行的编号,返回的第一行分配的是1,第二行是2,依此类推,这个伪字段可以用于限制查询返回的总行数,而且rownum不能以任何表的名称作为前缀。
Oracle超大记录数分页借助rownum
1、直接查询前10条记录
select * from book where rownum <=10
2、查询10-20条记录
select * from (select rownum as num, b.* from book b where rownum<=20) where num>=10
3、再加上排序
select * from (select a.*,rownum as num from (select * from book order by name desc) a where rownum <=20) where num>=10