分页查询
由于CBO优化模式下,Oracle可以将外层的查询条件推到内层查询中,以提高内层查询的执行效率。对于第一个查询语句,第二层的查询条件WHERE ROWNUM <= 100就可以被Oracle推入到内层查询中,这样Oracle查询的结果一旦超过了ROWNUM限制条件,就终止查询将结果返回了。
Oracle分页只能小于不能大于
select * from (select rownum rn,Stu.* from Stu where rownum<=100) ss where ss.rn>=60; select * from (selec rownum rn,t.* from ( select * from Stu where Cno='1' order by Grade desc ) t where rownum<=100) tt where tt.rn>=60;
mysql 分页
select * from Stu order by id limit 100000,30; select * from Stu where id>=(select id from Stu order by id limit 10000,1) limit 30;