oracle部分 oracle的分頁查詢

2021-09-25 06:10:22 字數 1141 閱讀 3809

-----oracle的分頁查詢

--問題:當乙個表中的資料量特別大的時候,如果一次性全部顯示給使用者,則造成頁面過於龐大,體驗極差。

--解決:使用分頁查詢

--使用:

--rownum關鍵字:oracle對外提供的自動給查詢結果編號的關鍵字,與每行的資料沒有關係。

--注意:rownum關鍵字只能做< <=的判斷,不能進行》 >=的判斷

select rownum ,e.* from emp e;

--查詢員工資訊的前5條資料 第一頁資料

select rownum r,e.* from emp e where rownum <=5;

select * from (select rownum r,e.* from emp e where rownum <=5) t where r>0;

--查詢員工資訊的6-10條資料 第二頁資料

select rownum r,e.* from emp e where rownum <=10;

select rownum,t.* from (select rownum r,e.* from emp e where rownum <=10) t where r>5;

--查詢員工資訊的11-15條資料 第三頁資料

select rownum r,e. * from emp e where rownum<=15;

select * from (select rownum r,e. * from emp e where rownum<=15) t where r>10;

--分頁規律總結:每頁顯示m條資料,查詢第n頁資料

select * from (select rownum r,e. * from 要分頁的表 e where rownum<=m*n) t where r>m*n-m ;

--要分頁的表既可以是真實的表,也可以是乙個查詢語句

--分頁查詢員工資訊按照工資排序

select * from (select rownum r,t.* from (select * from emp order by sal) t where rownum<=10 ) where r>5

select * from t

select * from emp

Oracle的部分概念

oracle公司的核心產品 目前最流行的資料庫 主要版本oracle8i 9i internet oracle10g 11g grid 基於c s系統結構,啟動乙個伺服器程序,用客戶端連線到伺服器上 資料庫存放各種資料檔案 控制檔案 日誌檔案 例項sga 後台程序,一般情況下乙個資料庫對應乙個例項,...

Oracle 部分函式

to char 是把日期或數字轉換為字串 to date 是把字串轉換為資料庫中的日期型別 to number 將字元轉化為數字 to char 使用to char函式處理數字 to char number,格式 to char salary,99,999.99 to char date,格式 to...

Oracle 部分語法

1.純文字標籤 cdata eg 符號 會被當做文字直接解析,即會把 裡的內容直接拼接在sql裡 2.日期轉字元 to char 日期格式的字段,要轉換成的格式 eg select to char sysdate,fmyyyy 年 mm 月 dd 日 from dual 2021年01月19日 3....