with check option使用
2016-04-19 00:11
429 查看
SQL> create table t(id number,name char(5));
Table created.
SQL> insert into t values(1,'a');
1 row created.
SQL> create view a1 as select * from t where id=1 with check option;
View created.
SQL> select * from a1;
ID NAME
---------- -----
1 a
SQL> insert into a1 values(2,'a');
insert into a1 values(2,'a')
*
ERROR at line 1:
ORA-01402: view WITH CHECK OPTIONwhere-clause violation
SQL> update a1 set id=2 where name='a';
update a1 set id=2 where name='a'
*
ERROR at line 1:
ORA-01402: view WITH CHECK OPTIONwhere-clause violation
在with check option的选项下,可以总结为
Table created.
SQL> insert into t values(1,'a');
1 row created.
SQL> create view a1 as select * from t where id=1 with check option;
View created.
SQL> select * from a1;
ID NAME
---------- -----
1 a
SQL> insert into a1 values(2,'a');
insert into a1 values(2,'a')
*
ERROR at line 1:
ORA-01402: view WITH CHECK OPTIONwhere-clause violation
SQL> update a1 set id=2 where name='a';
update a1 set id=2 where name='a'
*
ERROR at line 1:
ORA-01402: view WITH CHECK OPTIONwhere-clause violation
在with check option的选项下,可以总结为
1. update,要保证数据update之后能被视图查询出来,也就是要符合where的条件
2. insert,保证insert的数据能被视图查询出来
3. delete,有无 with check option都一样
4. 对于没有where字句的视图,使用with check option是多余的
相关文章推荐
- Android架构知识
- Zookeeper+HDFS+YARN监控
- studyphp环境软件Nginx隐藏index.php和Pathinfo模式配置例子
- 电脑手机微网站三站合一对企业有哪些优势?
- 最强大经典的php企业网站源码模板,一键安装就可以使用
- CenOS 7.1安装Docker、Docker-compose
- docker registrator配合consul使用的问题
- Centos 6.4打包tengine的rpm安装包教程
- linux云服务器硬盘分区及挂载
- nginx reload 命令报:nginx: [error] invalid PID number
- shell脚本基础知识
- System.getProperty
- 2.1Linux系统基础入门
- 2.2Linux命令行接口及基础命令
- 2.3Linux文件系统初步
- 2.4Linux文件系统初步
- PPA方式升级Nginx
- Linux CentOS下shell显示-bash-4.1$不显示用户名路径的解决方法
- CentOS7安装Maven
- CentOS7安装JDK