ORACLE分页查询SQL语句(最有效的分页)
1.无ORDER BY排序的写法。(效率最高)
(经过测试,此方法成本最低,只嵌套一层,速度最快!即使查询的数据量再大,也几乎不受影响,速度依然!)
SELECT * FROM (SELECT ROWNUM AS rowno, t.* FROM emp t WHERE hire_date BETWEEN TO_DATE (‘20060501‘, ‘yyyymmdd‘) AND TO_DATE (‘20060731‘, ‘yyyymmdd‘) AND ROWNUM <= 20) table_alias WHERE table_alias.rowno >= 10;
2.有ORDER BY排序的写法。(效率较高)
(经过测试,此方法随着查询范围的扩大,速度也会越来越慢哦!)
SELECT * FROM (SELECT tt.*, ROWNUM AS rowno FROM ( SELECT t.* FROM emp t WHERE hire_date BETWEEN TO_DATE (‘20060501‘, ‘yyyymmdd‘) AND TO_DATE (‘20060731‘, ‘yyyymmdd‘) ORDER BY create_time DESC, emp_no) tt WHERE ROWNUM <= 20) table_alias WHERE table_alias.rowno >= 10;
相关推荐
lklong 2020-11-22
oraclemch 2020-11-06
shilukun 2020-10-10
周嘉笙 2020-11-09
iilegend 2020-10-19
EricRay 2020-10-16
zhuzhufxz 2020-09-16
dataminer 2020-08-17
bfcady 2020-08-16
Hody 2020-08-16
FightFourEggs 2020-08-16
数据库设计 2020-08-16
Seandba 2020-08-16
Omega 2020-08-16
zjyzz 2020-08-16
yanghuatong 2020-08-16
ktyl000 2020-08-16
dbasunny 2020-08-16