无法修改表(使用 microsoft sql server management studio 2008)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4064149/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 08:04:46  来源:igfitidea点击:

Cannot modify table ( using microsoft sql server management studio 2008 )

sqlsql-serverssms

提问by gigi

I create 2 tables and another 1 with foreign keys to the other two.

我创建了 2 个表和另外 1 个表,外键指向另外两个表。

I realized I want to make some changes to table no 3.

我意识到我想对表 3 进行一些更改。

I try to update a field but I get an error "Saving changes is not permitted. The changes you have made require the following table to be dropped and re-created."

我尝试更新字段,但收到错误消息“不允许保存更改。您所做的更改需要删除并重新创建下表。”

I delete those 2 relationships but when I look at dependencies I see my table still depends on those 2 and I still cannot make any change to it.

我删除了这 2 个关系,但是当我查看依赖项时,我发现我的表仍然依赖于这 2 个关系,但我仍然无法对其进行任何更改。

What can I do?

我能做什么?

回答by Doggett

You can also enable saving changes that require dropping of tables by going to "tools->options->designers->Table and database designers" and unchecking "Prevent saving changes that require table re-creation"

您还可以通过转到“工具->选项->设计器->表和数据库设计器”并取消选中“防止保存需要重新创建表的更改”来启用保存需要删除表的更改

Be careful with this though, sometimes it'll drop a table without being able to recreate it, which makes you lose all data that was in the table.

但是要小心,有时它会删除一个表而无法重新创建它,这会使您丢失表中的所有数据。

回答by mnemonic

When using Microsoft SQL Server Management Studio 2012, the same message occurs. I used the script feature to do modifications which can be seen as a rather good workaround if you wanna use the designer only within a "safe" mode. Especially the GUI related to create a foreign key is not the best in my opinion. When using a script (alter table) for adding a fk, you are faster than using this GUI feature. When adding/writing a 'not' in prior to null, that's not a hard issue. (Removing an 'Allow Nulls' for a column refers to "Saving changes is not permitted" when using the designer.)

使用 Microsoft SQL Server Management Studio 2012 时,会出现相同的消息。我使用脚本功能进行修改,如果您只想在“安全”模式下使用设计器,这可以看作是一个相当好的解决方法。特别是与创建外键相关的 GUI 在我看来并不是最好的。使用脚本(更改表)添加 fk 时,比使用此 GUI 功能更快。在 null 之前添加/写入“not”时,这不是一个难题。(删除列的“允许空值”是指使用设计器时“不允许保存更改”。)