当前位置:  数据库>oracle

允许进行DML操作的视图条件

    来源: 互联网  发布时间:2017-06-06

    本文导语: 视图可以屏蔽某些基表的信息,或是join多个基表组成一个复杂查询,视图本身也是可以进行DML操作,但受一些条件的限制。 Oracle DML流程 PL/SQL“ ORA-14551: 无法在查询中执行 DML 操作”解决 MySQL常用DDL、DML、DCL语言整理(附样例...

视图可以屏蔽某些基表的信息,或是join多个基表组成一个复杂查询,视图本身也是可以进行DML操作,但受一些条件的限制。

Oracle DML流程

PL/SQL“ ORA-14551: 无法在查询中执行 DML 操作”解决

MySQL常用DDL、DML、DCL语言整理(附样例)

Oracle基本事务和ForAll执行批量DML练习

Oracle DML语句(insert,update,delete) 回滚开销估算

首先我们看下官方文档对视图进行DML操作的要求说明:

The following notes apply to updatable views:
 
An updatable view is one you can use to insert, update, or delete base table rows. You can create a view to be inherently updatable, or you can create an INSTEAD OF trigger on any view to make it updatable.
 
这里说明了两种可updateable(包括增删改基表)视图的方法:一是继承基表的视图,二是使用INSTEAD OF的触发器来实现任意视图的updatable。
 
To learn whether and in what ways the columns of an inherently updatable view can be modified, query the USER_UPDATABLE_COLUMNS data dictionary view. The information displayed by this view is meaningful only for inherently updatable views.
 
USER_UPDATABLE_COLUMNS数据字典视图可以找到视图的哪些字段可以进行增加、更新和删除。
 

For a view to be inherently updatable, the following conditions must be met:
 
对于这种updatable继承的视图,需要满足以下条件:
 
1. Each column in the view must map to a column of a single table. For example, if a view column maps to the output of a TABLE clause (an unnested collection), then the view is not inherently updatable.
 
2. The view must not contain any of the following constructs:
 
    A set operator
 
    A DISTINCT operator
 
    An aggregate or analytic function
 
    A GROUP BY, ORDER BY, MODEL, CONNECT BY, or START WITH clause
 
    A collection expression in a SELECT list
 
    A subquery in a SELECT list
 
    A subquery designated WITH READ ONLY
 
    Joins, with some exceptions, as documented in Oracle Database Administrator's Guide
 
3. In addition, if an inherently updatable view contains pseudocolumns or expressions, then you cannot update base table rows with an UPDATE statement that refers to any of these pseudocolumns or expressions.
 
4. If you want a join view to be updatable, then all of the following conditions must be true:
 
对于一个join视图,如果需要可updatable,那么就需要满足如下条件:
 
(1) The DML statement must affect only one table underlying the join.
 
DML必须仅影响一个join连接的表。
 
(2) For an INSERT statement, the view must not be created WITH CHECK OPTION, and all columns into which values are inserted must come from a key-preserved table. A key-preserved table is one for which every primary key or unique key value in the base table is also unique in the join view.
 
INSERT语句,不能使用WITH CHECK OPTION,并且所有待插入的列都来自于key-preserved表。
 
key-preserved表是指基表中每个主键或唯一键也必须是在join视图中唯一。
 
(3) For an UPDATE statement, the view must not be created WITH CHECK OPTION, and all columns updated must be extracted from a key-preserved table.
 
UPDATE语句,视图不能使用WITH CHECK OPTION创建,同样更新字段也必须来自于key-preserved表。
 
5. For a DELETE statement, if the join results in more than one key-preserved table, then Oracle Database deletes from the first table named in the FROM clause, whether or not the view was created WITH CHECK OPTION.
 
DELETE语句,如果join结果有多个key-preserved表,Oracle只会删除FROM子句中第一个表的记录,不管视图是否使用WITH CHECK OPTION。

更多详情见请继续阅读下一页的精彩内容:


    
 
 

您可能感兴趣的文章:

 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • JAVA的JDialog或JFame如何设置只允许扩大,不允许缩小
  • 求助!为什么linux下FTP允许windows登录而不允许linux登录?在线等
  • PHP 只允许指定IP访问(允许*号通配符过滤IP)
  • Linux 怎么让防火墙允许某个端口?怎么查看哪些端口已经被允许了?
  • motorola公司的j2me设计大赛允许个人报名么?怎么报名?
  • 怎么用正则表达是表示允许为空的字符串?
  • 怎么在防火墙中设置允许外部地址连接mysql数据库?
  • 我想让内核向网卡发送数据时,不是立即发送,而是等我允许时再发送
  • vector序列中是否允许有重复的元素?
  • 为什么登录时提示该窗口不允许登录管理员用户!
  • 如何让solaris8只允许几个IP访问
  • telnet下面如何支持文件传输?因为客户那边有安全需求,不允许用ftp和ssh
  • 运行程序后程序报错说操作不允许
  • linux下一个端口允许的同时最大连接数是多少
  • linux文件属性不允许被修改,chattr命令也出错~~
  • c#实现TextBox只允许输入数字
  • 配置mysql允许远程连接的方法
  • 允许远程用户访问mysql服务sql语句
  • resin允许目录访问,请问一下,如何禁止目录访问啊
  • WinForm下 TextBox只允许输入数字的小例子


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,