今天看視頻with read only和with check option這兩個東西聽的很暈,事實上以前就很暈
看見網上的一位朋友的講解還蠻清晰的,摘錄一下
建視圖有三種模式:
1、默認的模式,就是什麼也不加。
--可以更新的
create or replace view 視圖名 as
select xxx from 表名;
--不可以可以更新的create or replace view 視圖名 as
select xxx from 表名1 a,表名2 b where a.xxx=b.xxx;
--還有很多種情況不允許更新呢,比如視圖中用了distinct、group by 等
2、with read only 只讀視圖,不允許通過本視圖更新本表
create or replace view 視圖名 as
select xxx from 表名 with read only;
3、with check option 允許通過視圖更新本表,但是要check 視圖的where條件。
create or replace view 視圖名 as
select xxx from 表名 where id < 10 with check option;