oracle之数据处理之视图练习
生活随笔
收集整理的這篇文章主要介紹了
oracle之数据处理之视图练习
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
62. 查詢員工表中 salary 前 10 的員工信息.select last_name, salary
from (select last_name, salary from employees order by salary desc)
where rownum <= 10說明: rownum "偽列" ---- 數(shù)據(jù)表本身并沒有這樣的列, 是 oracle 數(shù)據(jù)庫為每個(gè)數(shù)據(jù)表 "加上的" 列. 可以標(biāo)識(shí)行號(hào).默認(rèn)情況下 rownum 按主索引來排序. 若沒有主索引則自然排序.注意: **對 ROWNUM 只能使用 < 或 <=, 而是用 =, >, >= 都將不能返回任何數(shù)據(jù). 63. 查詢員工表中 salary 10 - 20 的員工信息. select *
from(select rownum rn, temp.*from (select last_name, salaryfrom employees eorder by salary desc) temp
)
where rn > 10 and rn < 2164. 對 oralce 數(shù)據(jù)庫中記錄進(jìn)行分頁: 每頁顯示 10 條記錄, 查詢第 5 頁的數(shù)據(jù) select employee_id, last_name, salary
from (select rownum rn, employee_id, last_name, salaryfrom employees) e
where e.rn <= 50 and e.rn > 40 注意: **對 oracle 分頁必須使用 rownum "偽列"!select employee_id, last_name, salary
from (select rownum rn, employee_id, last_name, salaryfrom employees) e
where e.rn <= pageNo * pageSize and e.rn > (pageNo - 1) * pageSize
/*************************************************************************************************/
1. 使用表employees創(chuàng)建視圖employee_vu,其中包括姓名(LAST_NAME),員工號(hào)(EMPLOYEE_ID),部門號(hào)(DEPARTMENT_ID).
a) create or replace view employee_vu
b) as
c) select last_name,employee_id,department_id
d) from employees2. 顯示視圖的結(jié)構(gòu)
desc employee_vu;3. 查詢視圖中的全部內(nèi)容
SELECT * FROM employee_vu;4. 將視圖中的數(shù)據(jù)限定在部門號(hào)是80的范圍內(nèi)
a) create or replace view employee_vu
b) as
c) select last_name,employee_id,department_id
d) from employees
e) where department_id = 805. 將視圖改變成只讀視圖create or replace view employee_vu
as
select last_name,employee_id,department_id
from employees
where department_id = 80
with read only
?
總結(jié)
以上是生活随笔為你收集整理的oracle之数据处理之视图练习的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: =卡密
- 下一篇: Unity3D脚本访问与参数传递