如何编辑表格以启用 CASCADE DELETE? [英] How do I edit a table in order to enable CASCADE DELETE?
问题描述
我有一个代表用户的表格.当用户被删除时,我得到:
I have a table representing users. When a user is deleted I get:
DELETE 语句与 REFERENCE 约束冲突
DELETE statement conflicted with the REFERENCE constraint
显然,CASCADE DELETE
在SQL Server中并没有我想象的那么简单,需要将选项添加到表中.
Apparently, CASCADE DELETE
is not as easy as I imagined in SQL Server, and the option needs to be added to the table.
问题是:我不知道如何添加 CASCADE DELETE
选项.
The problem is: I cannot figure out how to add the CASCADE DELETE
option.
我正在使用:SQL Server 2008.任何想法如何做到这一点?
I'm using: SQL Server 2008. Any ideas how to do this?
推荐答案
首先阅读这篇 Microsoft 文章.阅读我.我在设计期间使用 GUI,所以这里是如何在 SSMS 中选择它的图片.添加到外键的语法是ON DELETE CASCADE"
Read this Microsoft article first. Read Me. I use the GUI during design so here is a picture of how it is selected in SSMS. The syntax added to the foreign key is " ON DELETE CASCADE "
这篇关于如何编辑表格以启用 CASCADE DELETE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!