标题: oracle数据的分页 [打印本页] 作者: 张兴康 时间: 2020-6-16 14:04 标题: oracle数据的分页 --查询前5条
Select rownum, emp.* from emp where rownum <=5;--查询第6条以后的数据
select * from emp where empno not in(select empno from emp where rownum <=5);--查询第6-10条数据
○ Select * from (select * from emp where empno not in(select empno from emp where rownum <=5)) where rownum <=5; ○ select * from emp where empno not in(select empno from emp where rownum <=5) and rownum <= 5;--总结
○ Select * from (select * from emp where empno not in(select empno from emp where rownum <= size * (page - 1))) where rownum <= size; ○ select * from emp where empno not in(select empno from emp where rownum <= size * (page - 1)) and rownum <= size; --排序后再分页查询
--将排序之后的数据编号(效率排第2)
select * from (select rownum rn, d.* from (select * from emp order by sal desc) d) where rn > 5 and rn < 11; --分页函数:row_number函数(效率排第1)
select row_number() over(order by sal desc) rn, emp.* from emp; --分页
select * from (select row_number() over(order by sal desc) rn, emp.* from emp) where rn > 5 and rn < 11; 作者: 张兴康 时间: 2020-6-16 14:05 作者: fteair 时间: 2020-6-16 14:19 作者: 张兴康 时间: 2020-6-17 14:13