无法修改表(使用microsoft sql server management studio 2008)
我创建了 2 个表和另外 1 个表,其中包含另外两个表的外键。
我意识到我想对表 3 进行一些更改。
我尝试更新字段,但收到错误“不允许保存更改。您所做的更改需要删除并重新创建下表。”
我删除了这两个关系,但是当我查看依赖关系时,我发现我的表仍然依赖于这两个关系,而且我仍然无法对其进行任何更改。
我能做些什么?
I create 2 tables and another 1 with foreign keys to the other two.
I realized I want to make some changes to table no 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.
What can I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以通过转到“工具->选项->设计器->表和数据库设计器”并取消选中“防止保存需要重新创建表的更改”来启用保存需要删除表的更改,
但请小心这一点,有时它会删除表而无法重新创建它,这会使您丢失表中的所有数据。
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.
使用 Microsoft SQL Server Management Studio 2012 时,会出现相同的消息。
我使用脚本功能进行修改,如果您只想在“安全”模式下使用设计器,这可以看作是一个相当好的解决方法。
特别是与创建外键相关的 GUI 在我看来并不是最好的。当使用脚本(alter table)添加 fk 时,比使用此 GUI 功能更快。
当在 null 之前添加/写入“not”时,这不是一个难题。 (删除列的“允许空值”是指使用设计器时“不允许保存更改”。)
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.)