oracle 分页

-- oracle分页:
  select e.*, rownum rn from (select * from emp) e;
  select e.*, rownum rn from (select * from emp) e where rn < 5; -- 这个不对
  select e.*, rownum rn from (select * from emp) e where rownum <= 10;
  select e.*, rownum rn from (select * from emp) e where rownum <= 10 and rownum >=5; -- 这个也没有结果
  select * from (select e.*, rownum rn from (select * from emp) e where rownum <= 10) o where rn >= 5;
-- 如果要指定查询列,只需要修改最里层的
  select * from (select e.*, rownum rn from (select ename, sal from emp) e where rownum <= 10) o where rn >= 5;
  select o.ename, o.sal from (select e.*, rownum rn from (select ename, sal from emp) e where rownum <= 10) o where rn >= 5;
-- 排序也只需要修改最里层即可
  select * from (select e.*, rownum rn from (select ename, sal from emp order by sal) e where rownum <= 10) o where rn >= 5;

posted @ 2018-07-09 04:46  zhuangrunwei  阅读(130)  评论(0编辑  收藏  举报