Oracle Pagination

1, order by is logical order, while rownum is based on the physical position; in a temporary table generated by a subquery, the logical order and the physical order are one and the same.

2, without order by and only <=

select *
from T_PF_DEP
where ROWNUM <= 5000;

3, without order by and both <= and >

select *
from (select * from T_PF_USER where ROWNUM <= 500) t
where ROWNUM > 0;

4, with order by

select *
from (select * from T_PF_DEP order by T_PF_DEP.DEPCODE) t
where ROWNUM <= 5000;
select *
from (select * from (select * from T_PF_DEP order by T_PF_DEP.DEPCODE) t where ROWNUM <= 500) tt
where ROWNUM > 0;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章