当主表更新时,外键是否自动更新? [英] Does the foreign keys automatically get updated as primary table is updated?
问题描述
以上是我的简单的数据库设计,只是想获得有关事情发生的信息,因为我真的是数据库的新手。以下是我的问题:
-
当我在wall表中更新wall_id时,wall_categories表中的wall_id是否也会更新?作为
中的wall_id wall_categories表指向wall表中的wall_id。
-
与walls表中的desktop_id相同,因为它是引用desktop_id的外键在desktop_wall表中,所以当我更新
桌面desktop_id在桌面桌面desktop_id deskotp_wall也
得到更新? -
如果它没有更新默认情况下,如何做到这一点?
非常感谢!
此功能称为级联参照完整性。定义外键约束时是可选的。在这里描述启用它的语法(Micorosoft SQL,但语法是标准的,大多数DBMS支持它): .com / en-us / library / ms186973(v = sql.105).aspxrel =nofollow> http://technet.microsoft.com/en-us/library/ms186973(v = sql.105) .aspx
Above is my simple database design, just wanted to gain information about how things happen as I'm really new at database. Following are my questions:
as I update wall_id in walls table, does the wall_id in wall_categories table also get updated? as the wall_id in wall_categories table references to wall_id in walls table.
same with desktop_id in walls table since it is a foreign key referencing to desktop_id in desktop_wall table, so when I update desktop_id in walls table does the desktop_id in deskotp_wall also gets updated?
if it does not update by default, how can this be done?
Thanks a lot!
This feature is called cascading referential integrity. It's optional when you define a foreign key constraint. The syntax to enable it is described here (Micorosoft SQL but the syntax is standard and most DBMSs support it):
http://technet.microsoft.com/en-us/library/ms186973(v=sql.105).aspx
这篇关于当主表更新时,外键是否自动更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!