Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 冲浪宝典 > 网络资源 > 实例分析简单介绍o型约束
【标  题】:实例分析简单介绍o型约束
【关键字】:
【来  源】:http://www.cublog.cn/u/22472/showart.php?id=237642

实例分析简单介绍o型约束

Your Ad Here
实例分析简单介绍o型约束
  
      作者:hongsy
      时间:2007-01-25 9:50
      参考资料:Rakesh.V.Chakote的Whats Constraint Type “O” ?
 

   当基于一个单独的基表创建一个视图时,在该视图上执行的DML操作就像基表上执行一样。如果打算在视图上限制DML操作,可以在创建视图时使用with read only选项来控制。
   eg1:
     
      正常的视图:
 hongsy@test>create or replace test_test
   2  as select * from tttt;
 create or replace test_test
     *
 ERROR 位于第 1 行:
 ORA-00922: 缺少或无效选项

 hongsy@test>l1
   1* create or replace test_test
 hongsy@test>c/replace/replace view
   1* create or replace view test_test
 hongsy@test>/
 视图已建立。
 hongsy@test>insert into test_test(departmentcode,departmentname,departshortname,departtypecode,hasstudent,hascourse,status)
   2  values('16','test_test','test_test','1','Y','Y','有效');
 已创建 1 行。
       以上在视图上的操作就像在其表上操作一样。

   eg2:
       使用了with read only 的视图:
     
 hongsy@test>create or replace view test_readonly
   2  as select * from tttt with read only;
 视图已建立。
       当以上视图创建成功的时候,oracle内部在该视图上增加了一个用于限制使用DML操作的“o”型约束。
 hongsy@test>select constraint_name,constraint_type
   2  from user_constraints
   3  where table_name=upper('test_readonly');
 CONSTRAINT_NAME                C                                               
 ------------------------------ -                                               
 SYS_C0020995                   O   
 此时不能在test_readonly上做任何DML操作,不能会报错:
 hongsy@test>insert into test_readonly(departmentcode,departmentname,departshortname,departtypecode,hasstudent,hascourse,status)
   2  values('17','test_readonly','test_readonly','1','Y','Y','有效');
 insert into test_readonly(departmentcode,departmentname,departshortname,departtypecode,hasstudent,hascourse,status)
      *
 ERROR 位于第 1 行:
 ORA-01733: 此处不允许虚拟列
 版权所有,随意转载,不过请附上出处!非常感谢您的配合。
PL/SQL BULK COLLECT INTO:【上一篇】
PL/SQL FORALL:【下一篇】
【相关文章】
没有相关文章
【随机文章】
  • VNC的安装与使用
  • JScript 方法 - anchor 方法
  • 条款6:析构函数里对指针成员调用delete
  • 我的"Java开发通讯簿系统"开发经历 ㈤
  • 关机重启
  • 2004-9-9后 china-pub购书单
  • EurekaLog Enterprise v4.2.3 with Full Source
  • SQL导出到MYSQL的简单方法
  • how to find "oracle在各种linux上的安装手册"
  • 为Windows 2003加装视频压缩
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.