且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL Server:删除具有外键约束的行:事务可以覆盖约束吗?

更新时间:2023-01-30 11:21:17

不要使用级联删除,可以导致严重的性能问题。***的过程是按照从最低子表到父表的顺序执行删除。

Do not use cascade delete, you can cause serious performance issues that way. The best procedure is to do the deletes in order from the lowest child table up to the parent table.

禁用外键是出现数据完整性问题的处方。唯一需要做的事情是DBA,他是非常有经验的,很好地意识到可能导致的问题。如果你问这个问题,你还没有足够的经验来使用这种技术。记住当你禁用FK,你禁用所有人,而不只是你的进程。

Disabling the foreign keys is a prescription for having data integrity problems. The only time something like that should be done is by a DBA who is extremely experienced and well aware of the issues that could cause. If you are asking this question, you are not yet experienced enough to use that technique. Remember when you disable the FK, you disable it for everyone not just your process.