Oracle 分页算法汇总

这是我找到的一些关于Oracle分页的算法,大家那里还有没有其他好的算法没?我们大家一起分享一下!


-- Oracle 分页算法一
select * from (
select t.*,rownum rn from (select * from help) t
-- 20 = (currentPage-1) * pageSize + pageSize
where rownum <= 20
)
-- 10 = (currentPage-1) * pageSize
where rn > 10;

-- Oralce 分页算法二
-- 20 = (currentPage-1) * pageSize + pageSize
select * from help where rownum<=20
minus
-- 10 = (currentPage-1) * pageSize
select * from help where rownum<=10;

-- 12c最新的分页方式
-- 返回前3行
select * from help where 1 = 1 order by info fetch next 3 rows only;
-- 返回并列排名的行
select * from help where 1 = 1 order by info fetch next 3 rows with ties;

-- 分页
select * from help where 1 = 1 order by info offset 10 rows fetch next 1 rows only;

-- 返回10%行
select * from help where 1 = 1 order by info fetch first 10 percent rows only;
相关推荐
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页