視圖與索引
創建視圖
creat view 視圖名 (列名1,列名2…)
as
select 查詢子句
whith check = option
eg:建立數學學院(MA)和學生視圖(V_MA),並進行修改和插入操作時仍需要保證該視圖只有數學學院的學生
creat view v_ma
as
select sno,sname,birthdate
from s
where college='ma'
whith check = option
--此語句表示對該視圖操作時,會驗證條件
修改視圖
alter view 視圖名 (列名1,列名2…)
as
select 查詢子句
whith check = option
eg:修改視圖v_ma,並要求該視圖只查詢數學學院(ma)的男學生
creat view v_ma
as
select sno,sname,birthdate
from s
where college='ma' and sex='男'
whith check = option
--此語句表示對該視圖操作時,會驗證條件
刪除視圖
drop view 視圖名
使用視圖
創建索引
作用:加快檢索表中數據的方法,類似於書的目錄查找