Teradata:添加外键约束时 CHECK OPTION 的目的是什么?
我似乎无法在互联网上找到一个好的资源来解释添加外键约束时使用的检查选项
。我将其视为带检查选项
和不带检查选项
。
I can't seem to find a good resource on the internet that explains the check option
that's used when adding a foreign key constraint. I've seen it as with check option
and with no check option
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
WITH CHECK OPTION
短语添加到REFERENCES
约束会告诉数据库在单个事务或请求的粒度上强制执行定义的 RI 约束。系统会将子表和父表连接在一起以查看是否存在不一致。如果发现不一致,整个事务将在TERADATA
会话模式下回滚,或在ANSI
模式下回滚问题请求。相反,如果您指定
WITH NO CHECK OPTION
,数据库不会强制执行 RI。因此,当父表值不存在时,子表中的记录可以使用 NULL 以外的值引用父表。RI 执行在 Teradata 中是一把双刃剑,必须仔细评估您最终决定如何执行它。 Teradata 手册确实阐明了您需要考虑的许多事项,以帮助您做出决定。话虽如此,在我与 Teradata 合作的 15 年里,我还没有开发过在数据仓库中强制实施 RI 的系统。 对、错或无关紧要。
希望这会有所帮助。
The addition of
WITH CHECK OPTION
phrase to aREFERENCES
constraint tells the database to enforce the defined RI constraint at the granularity of a single transaction or request. The system will join the child and parent tables together to see if there is an inconsistency. If an inconsistency is found the entire transaction is rolled back inTERADATA
session mode or the problem request inANSI
mode.Transversely if you specify
WITH NO CHECK OPTION
the database does not enforce the RI. Thus a record in a child can reference the parent using a value other than NULL when the parent table value does not exist.RI enforcement is a double edged sword in Teradata and must be evaluated carefully on how you ultimately decide to enforce it. The Teradata Manuals do spell out many of the things that you need to consider to help make your decision. That being said, in the past 15 years that I have been working with Teradata, I have not yet worked on a system where RI was enforced in the data warehouse. Right, Wrong, or Indifferent.
Hope this helps.