zchbaby2000
作者zchbaby2000·2013-01-15 10:28
软件开发工程师·IBM

ON DELETE NO ACTION与ON DELETE RESTRICT区别

字数 816阅读 1135评论 0赞 0
只有在及个别的情况下会导致区别,前者是在其他约束的动作之后执行,后者具有最高的优先权执行。

一个例子:(DB2 SQL Reference Vol 2, 383页)

Table T1 is a parent of table T3; delete rule as noted below.
Table T2 is a parent of table T3; delete rule CASCADE.

CREATE VIEW V1 AS SELECT * FROM T1 UNION ALL SELECT * FROM T2
DELETE FROM V1

If table T1 is a parent of table T3 with a delete rule of RESTRICT, a restrict
violation will be raised (SQLSTATE 23001) if there are any child rows for
parent keys of T1 in T3.
If table T1 is a parent of table T3 with a delete rule of NO ACTION, the
child rows may be deleted by the delete rule of CASCADE when deleting
rows from T2 before the NO ACTION delete rule is enforced for the deletes
from T1. If deletes from T2 did not result in deleting all child rows for
parent keys of T1 in T3, then a constraint violation will be raised
(SQLSTATE 23504)

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

0

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

  • transaction log full when doing disk init
    评论 0 · 赞 0
  • Sybase tempdb调整
    评论 0 · 赞 0
  • Sybase系统表
    评论 0 · 赞 0
  • Oracle ASM系列视频
    评论 0 · 赞 0
  • IBM存储
    评论 0 · 赞 0
  • 相关文章

    相关问题

    相关资料

    X社区推广