ORACLE分頁查詢SQL語法
來源:易賢網(wǎng) 閱讀:1051 次 日期:2014-08-25 10:57:22
溫馨提示:易賢網(wǎng)小編為您整理了“ORACLE分頁查詢SQL語法”,方便廣大網(wǎng)友查閱!

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

--(經(jīng)過測試,此方法成本最低,只嵌套一層,速度最快!即使查詢的數(shù)據(jù)量再大,也幾乎不受影響,速度依然!) ­

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;

--(經(jīng)過測試,此方法隨著查詢范圍的擴(kuò)大,速度也會(huì)越來越慢哦!) &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;

--(此方法隨著查詢數(shù)據(jù)量的擴(kuò)張,速度會(huì)越來越慢哦!) &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;

--(此方法隨著查詢范圍的擴(kuò)大,速度會(huì)越來越慢哦!) &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;

--(語法風(fēng)格與傳統(tǒng)的SQL語法不同,不方便閱讀與理解,為規(guī)范與統(tǒng)一標(biāo)準(zhǔn),不推薦使用。) &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技術(shù)專欄

更多信息請查看數(shù)據(jù)庫
易賢網(wǎng)手機(jī)網(wǎng)站地址:ORACLE分頁查詢SQL語法
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國考·省考課程試聽報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)