Teradata:添加外键约束时 CHECK OPTION 的目的是什么?

发布于 2024-12-22 19:20:03 字数 100 浏览 3 评论 0原文

我似乎无法在互联网上找到一个好的资源来解释添加外键约束时使用的检查选项。我将其视为带检查选项不带检查选项

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

这样的小城市 2024-12-29 19:20:03

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 a REFERENCES 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 in TERADATA session mode or the problem request in ANSI 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文