Oracle数据库分页的三种方法
-- 不能對ROWNUM使用>(大于1的數(shù)值)、>=(大于或等于1的數(shù)值)、=(大于或等于1的數(shù)值),否則無結(jié)果
-- 所以直接用只能從1開始
-- rownum >10 沒有記錄,因?yàn)榈谝粭l不滿足去掉的話,第二條的rownum又成了1,所以永遠(yuǎn)沒有滿足條件的記錄。
select * from student where rownum>=1;
--如果想要用rownum不從1開始,需按下面方法使用
select a1.* from (select student.*,rownum rn from student) a1 where rn >5;
--分頁查詢一
select * from (select a1.*,rownum rn from (select * from student) a1 where rownum <=5) where rn>=2;
--分頁查詢二
select a1.* from (select student.*,rownum rn from student where rownum <=5) a1 where rn >=3;
--分頁查詢?nèi)?/span>
select a1.* from (select student.*,rownum rn from student) a1 where rn between 3 and 5;
總結(jié)
以上是生活随笔為你收集整理的Oracle数据库分页的三种方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Word怎么将一个文档拆分成几个小文档
- 下一篇: Linux MYSQL 数据库