sql2005,with check option 在视图与基表中的用法
来源:互联网 发布:淘宝原味胖次 编辑:程序博客网 时间:2024/06/05 08:19
create view stu8_view9 as select * from stu8 where ssex ='女'
create view stu8_view10 as select * from stu8 where ssex = '女'
with check option
create view stu8_view11 as select * from stu8 where ssex = '女'
with check option
------------------------------
select * into stu8_view8_view9_view10_view11 from (
select a.s#,a.sname,a.sage,a.ssex from stu8 a
inner join stu8_view8 b on b.s#=a.s#
inner join stu8_view9 c on c.s#=a.s#
inner join stu8_view10 d on d.s#=a.s#
inner join stu8_view11 e on e.s#= a.s#
and b.s#=a.s# and c.s#=a.s# and d.s#=a.s# and e.s#=a.s#
and c.s#=b.s# and d.s#=b.s# and e.s#=b.s#
and d.s#=c.s# and e.s# = c.s#
and e.s# = e.s# ) f ----t 插入新表成功
---------------------------------
select * from stu8_view8_view9_view10_view11 -----s# 42 45 17 23 11
drop table stu8_view8_view9_view10_view11
-----------
select * from stu8
select * from stu8_view8
select * from stu8_view9
select * from stu8_view10
select * from stu8_view11
---------------
update 作用于where=条件的字段
update stu8 set ssex ='男' where s#=42
---stu8 记录改变; stu8_view8, stu8_view9, stu8_view10, stu8_view11少了一条记录
update stu8 set ssex ='女' where s#=3
----stu8 记录改变; stu8_view8, stu8_view9, stu8_view10, stu8_view11多了一条记录
update stu8_view8 set ssex ='男' where s#=11 ----t stu8_view8 没有WITH CHECK OPTION 约束
----stu8 记录改变; stu8_view8, stu8_view9, stu8_view10, stu8_view11少了一条记录
update stu8_view10 set ssex ='男' where s#=11 ----f stu8_view10 有WITH CHECK OPTION 约束
-------stu8 , stu8_view8, stu8_view9, stu8_view10, stu8_view11记录不改变
Msg 550, Level 16, State 1, Line 1
试图进行的插入或更新已失败,原因是目标视图或者目标视图所跨越的某一视图指定了 WITH CHECK OPTION,而该操作的一个或多个结果行又不符合 CHECK OPTION 约束的条件。
语句已终止。
-----------
update 作用于不是 where=条件 的字段
update stu8 set sname =null where s#=11
-------stu8 , stu8_view8, stu8_view9, stu8_view10, stu8_view11记录改变
update stu8_view8 set sname ='李正' where s#=17
-------stu8 , stu8_view8, stu8_view9, stu8_view10, stu8_view11记录改变
update stu8_view10 set sname =null where s#=42
-------stu8 , stu8_view8, stu8_view9, stu8_view10, stu8_view11记录改变
---------------------------------
insert
insert into stu8 values('XXXX','1994-5-1','男',50)
-------stu8 多了一条记录, stu8_view8, stu8_view9, stu8_view10, stu8_view11记录不改变
insert into stu8_view8 values('XXXX','1994-5-1','男',51) ----t stu8_view8 没有WITH CHECK OPTION 约束
-------stu8 多了一条记录, stu8_view8, stu8_view9, stu8_view10, stu8_view11记录不改变
insert into stu8_view10 values('XXXX','1994-5-1','男',52) ----f stu8_view10 有WITH CHECK OPTION 约束
------Msg 550, Level 16, State 1, Line 1
试图进行的插入或更新已失败,原因是目标视图或者目标视图所跨越的某一视图指定了 WITH CHECK OPTION,而该操作的一个或多个结果行又不符合 CHECK OPTION 约束的条件。
语句已终止。------stu8 , stu8_view8, stu8_view9, stu8_view10, stu8_view11记录不改变
insert into stu8 values('XXXX','1994-5-1','女',53)
-------stu8 , stu8_view8, stu8_view9, stu8_view10, stu8_view11均多了一条记录
insert into stu8_view8 values('XXXX','1994-5-1','女',54)
-------stu8 , stu8_view8, stu8_view9, stu8_view10, stu8_view11均多了一条记录
insert into stu8_view10 values('XXXX','1994-5-1','女',55)
-------stu8 , stu8_view8, stu8_view9, stu8_view10, stu8_view11均多了一条记录
delete
delete stu8 where s#=42
-------stu8 , stu8_view8, stu8_view9, stu8_view10, stu8_view11均少了一条记录
delete stu8_view8 where s#=11
-------stu8 , stu8_view8, stu8_view9, stu8_view10, stu8_view11均少了一条记录
delete stu8_view10 where s#=17
-------stu8 , stu8_view8, stu8_view9, stu8_view10, stu8_view11均少了一条记录
-----XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
以上是 where= 条件 部分,还有 where> 、< 的情况、
- sql2005,with check option 在视图与基表中的用法
- 视图中的with check option
- 视图 WITH CHECK OPTION
- WITH CHECK OPTION用法
- -------视图with check option选项-------------------
- SQL中的with check option
- 创建视图时with check option问题
- 创建视图时with check option问题
- ORACLE 视图的 with check option
- 视图中with check option的作用
- 关于Oracle视图with check option
- ORACLE 视图的 with check option
- 视图with check option选项详解
- 创建视图的with check option选项。
- 创建视图时with check option问题
- oracle 创建视图 with check option
- oracle 下WITH CHECK OPTION用法
- oracle 下WITH CHECK OPTION用法
- void及void指针含义的深刻解析
- 使用clock函数实现跨平台的精确计时
- 去掉Activity跳转动画
- WeChall Training: Stegano I
- mysql的get请求
- sql2005,with check option 在视图与基表中的用法
- Adapter.getView中inflater.inflate(R.layout.pending_list_item, parent, false);方法处理
- C语言字节对齐详解
- java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
- Springmvc +JNDI 在Tomcat下 配置数据源 .
- JS动态修改页面EasyUI datebox不生效、EasyUI动态添加Class、EasyUI动态渲染解析解决方案
- Guest与virtio netdev的交互方式
- OSSEC源代码创建VS2010项目
- Java多线程生成测试文件