自动创建外键是否意味着引用完整性?
如果我创建外键,引用完整性是自动的吗?我还需要设置其他什么才能使级联工作吗?
编辑:例如,在 postgres 中。我所说的自动是指我不需要设置任何其他内容即可使 RI 工作。删除。我猜测 FK 意味着它将确保插入的 FK 中存在数据。
If I create a foreign key is referential integrity automatic? Do I have to set anything else to make cascading work?
edit: for example, in postgres. I mean by automatic that I don't need to set anything else up to make RI work. Deletes. I am guessing though a FK means that it will insure data is present in the FK for the insert.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,一旦创建外键,就会强制执行引用完整性。您还可以定义其他选项,例如级联更新和删除。通常,这是用于创建外键的相同语法的一部分,并且通常必须在创建外键时指定 - 至少在标准 SQL 中是这样的。
Yes, Referential Integrity is enforced as soon as you create a foreign key. You can define other options as well, such as cascading updates and deletes. Usually this is part of the same syntax used to create the foreign key and it normally has to be specified when the foreign key is created - at least that's how it works in standard SQL.
引用完整性不仅仅是外键。
当涉及到级联时,这取决于您如何定义外键以及您正在使用的 RDBMS。
There is more to referential integrity than foreign keys.
When it comes to cascades, it depends on how you define the foreign keys and on the RDBMS you are using.
不。
详细信息取决于您正在使用的数据库系统,但类似“ON DELETE CASCADE”的内容可能就是您想要的。
No.
The details depend on the database system that you are using, but something like "ON DELETE CASCADE" is probably what you want.