Oracle分页查询的提升阶段
--Oracle分页查询
--简单初级阶段
SELECT * FROM (SELECT * FROM score s ORDER BY math DESC) WHERE ROWNUM = 1;
--中级阶段,基本实现了结果,但仍有可优化的空间!
SELECT *
FROM (SELECT so.*, ROWNUM rw
FROM (SELECT * FROM score s ORDER BY math DESC) so) sa
WHERE sa.rw >= 1
AND sa.rw <= 4;
--究极形态...!效率最高!
SELECT *
FROM (SELECT SO.*, ROWNUM RW
FROM (SELECT * FROM SCORE S ORDER BY MATH DESC) SO
WHERE ROWNUM <= 4) SA
WHERE SA.RW >= 1;
--简单初级阶段
SELECT * FROM (SELECT * FROM score s ORDER BY math DESC) WHERE ROWNUM = 1;
--中级阶段,基本实现了结果,但仍有可优化的空间!
SELECT *
FROM (SELECT so.*, ROWNUM rw
FROM (SELECT * FROM score s ORDER BY math DESC) so) sa
WHERE sa.rw >= 1
AND sa.rw <= 4;
--究极形态...!效率最高!
SELECT *
FROM (SELECT SO.*, ROWNUM RW
FROM (SELECT * FROM SCORE S ORDER BY MATH DESC) SO
WHERE ROWNUM <= 4) SA
WHERE SA.RW >= 1;
想继续深入,可参照大牛的这篇文章:
http://blog.csdn.net/anxpp/article/details/51534006
鄙视'砖家'和'叫兽'