足球游戏_中国足彩网¥体育资讯$

ORACLE分页查询SQL语法
来源:易贤网 阅读:954 次 日期:2014-08-25 10:57:22
温馨提示:易贤网小编为您整理了“ORACLE分页查询SQL语法”,方便广大网友查阅!

--1:无ORDER BY排序的写法。(效率最高) ­

--(经过测试,此方法成本最低,只嵌套一层,速度最快!即使查询的数据量再大,也几乎不受影响,速度依然!) ­

SELECT * ­

FROM (Select ROWNUM AS ROWNO, T.* ­

from k_task T ­

where Flight_date between to_date('20060501', 'yyyymmdd') and ­

to_date('20060731', 'yyyymmdd') ­

AND ROWNUM <= 20) TABLE_ALIAS &shy;

WHERE TABLE_ALIAS.ROWNO >= 10; &shy;

&shy;

--2:有ORDER BY排序的写法。(效率最高) &shy;

--(经过测试,此方法随着查询范围的扩大,速度也会越来越慢哦!) &shy;

SELECT * &shy;

FROM (SELECT TT.*, ROWNUM AS ROWNO &shy;

FROM (Select t.* &shy;

from k_task T &shy;

where flight_date between to_date('20060501', 'yyyymmdd') and &shy;

to_date('20060531', 'yyyymmdd') &shy;

ORDER BY FACT_UP_TIME, flight_no) TT &shy;

WHERE ROWNUM <= 20) TABLE_ALIAS &shy;

where TABLE_ALIAS.rowno >= 10; &shy;

&shy;

--3:无ORDER BY排序的写法。(建议使用方法1代替) &shy;

--(此方法随着查询数据量的扩张,速度会越来越慢哦!) &shy;

SELECT * &shy;

FROM (Select ROWNUM AS ROWNO, T.* &shy;

from k_task T &shy;

where Flight_date between to_date('20060501', 'yyyymmdd') and &shy;

to_date('20060731', 'yyyymmdd')) TABLE_ALIAS &shy;

WHERE TABLE_ALIAS.ROWNO <= 20 &shy;

AND TABLE_ALIAS.ROWNO >= 10; &shy;

--TABLE_ALIAS.ROWNO  between 10 and 100; &shy;

&shy;

--4:有ORDER BY排序的写法.(建议使用方法2代替) &shy;

--(此方法随着查询范围的扩大,速度会越来越慢哦!) &shy;

SELECT * &shy;

FROM (SELECT TT.*, ROWNUM AS ROWNO &shy;

FROM (Select * &shy;

from k_task T &shy;

where flight_date between to_date('20060501', 'yyyymmdd') and &shy;

to_date('20060531', 'yyyymmdd') &shy;

ORDER BY FACT_UP_TIME, flight_no) TT) TABLE_ALIAS &shy;

where TABLE_ALIAS.rowno BETWEEN 10 AND 20; &shy;

&shy;

&shy;

--5另类语法。(有ORDER BY写法) &shy;

--(语法风格与传统的SQL语法不同,不方便阅读与理解,为规范与统一标准,不推荐使用。) &shy;

With partdata as( &shy;

SELECT ROWNUM AS ROWNO, TT.*  FROM (Select * &shy;

from k_task T &shy;

where flight_date between to_date('20060501', 'yyyymmdd') and &shy;

to_date('20060531', 'yyyymmdd') &shy;

ORDER BY FACT_UP_TIME, flight_no) TT &shy;

WHERE ROWNUM <= 20) &shy;

Select * from partdata where rowno >= 10; &shy;

&shy;

--6另类语法 。(无ORDER BY写法) &shy;

With partdata as( &shy;

Select ROWNUM AS ROWNO, T.* &shy;

From K_task T &shy;

where Flight_date between to_date('20060501', 'yyyymmdd') and &shy;

To_date('20060531', 'yyyymmdd') &shy;

AND ROWNUM <= 20) &shy;

Select * from partdata where Rowno >= 10; &shy;

-

中国足彩网信息请查看IT技术专栏

中国足彩网信息请查看数据库
易贤网手机网站地址:ORACLE分页查询SQL语法
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 足球游戏_中国足彩网¥体育资讯$ 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标