create view with check option
手冊介紹:
WITH CHECK OPTION Specify WITH CHECK OPTION to indicate that Oracle
Database prohibits any changes to the table or view that would produce rows that are
not included in the subquery. When used in the subquery of a DML statement, you
can specify this clause in a subquery in the FROM clause but not in subquery in the
WHERE clause.
with check option可以這麼解釋:透過檢視進行的修改,必須也能透過該檢視看到修改後的結果。比如你insert,那麼加的這條記錄在重新整理檢視後必須可以看到;如果修改,修改完的結果也必須能透過該檢視看到;如果刪除,當然只能刪除檢視裡有顯示的記錄。
SQL> select * from dept;
DEPT_ID DEPT_NAME
---------- --------------------
1 a
2 b
SQL> create view v_dept as select * from dept where dept_id>1 with check option;
檢視已建立。
SQL> insert into v_dept values(1,'a');
insert into v_dept values(1,'a')
*
第 1 行出現錯誤:
ORA-01402: 檢視 WITH CHECK OPTIDN where 子句違規
SQL> insert into v_dept values(2,'a');
已建立 1 行。
SQL> rollback;
回退已完成。
SQL> select * from v_dept;
DEPT_ID DEPT_NAME
---------- --------------------
2 b
SQL> update v_dept set dept_id=1;
update v_dept set dept_id=1
*
第 1 行出現錯誤:
ORA-01402: 檢視 WITH CHECK OPTIDN where 子句違規
SQL> update v_dept set dept_id=3;
已更新 1 行。
SQL> rollback;
回退已完成。
[@more@]來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9533994/viewspace-1022930/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1MySql
- onclick="return check()" 和 onclick="check()" 區別
- option新增空白
- jquery獲得option的值和對option進行操作jQuery
- Check if String is HappyAPP
- The option-critic architecture
- 蘋果電腦上神奇的Option鍵,巧用option鍵提升效率蘋果
- Jquery 動態增加option及獲取值 遍歷option相關方法jQuery
- create_singlethread_workqueue, create_workqueuethread
- check_document_position
- CHECK_INTERFACE作用
- Kotlin Type? vs Scala OptionKotlin
- SAP WM中階Storage Type的Capacity Check – Usage check based on SUT
- 括展actuator health check
- [LintCode] Check Full Binary Tree
- Mysql replication check指令碼MySql指令碼
- Check connection related issue of mysqlMySql
- check memcached process and restart if downREST
- SAP WM中階儲存型別的Capacity Check – Usage check based on material型別
- Docker create命令Docker
- create-a-page
- create-a-document
- create index .. onlineIndex
- SQL__CREATESQL
- Object.create()Object
- Android自定義View:View(二)AndroidView
- [Typescript] The module & moduleResolution Option in tsconfig.jsonTypeScriptJSON
- The hidden power of option-click in vscode explorerVSCode
- Echarts中Option屬性設定Echarts
- Rust 程式設計,Option 學習Rust程式設計
- 期權——put-call option parity
- YUI Datatable dropdown option value text definationUI
- the --skip-grant-tables option so it cannot
- Dynamic Web Project option missing in Eclipse KeplerWebProjectEclipse
- post請求帶來的option
- 升級check SQL01SQL
- [LintCode/LeetCode] Check Sum of K PrimesLeetCode
- 在SAP C4C裡觸發SAP ERP的ATP check和Credit check
- ViewView