SQL 不允许保存更改。您所做的更改需要删除并重新创建以下表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20123606/
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
Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created
提问by wmrodrigues
When I try to alter a data type of my table I get this horrible message from SQL Management Studion: "Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created". I already tried to do the modification by T-SQL and it worked, but why can't I just do this by design mode? I'm using SQL Server 2008 R2.
当我尝试更改表的数据类型时,我从 SQL Management Studion 收到一条可怕的消息:“不允许保存更改。您所做的更改需要删除并重新创建以下表”。我已经尝试通过 T-SQL 进行修改并且它起作用了,但是为什么我不能通过设计模式来做到这一点?我正在使用 SQL Server 2008 R2。
回答by Stuart Ainsworth
I would strongly suggest that you use T-SQL to make changes, or at the very least, preview the scripts that the Designers generate before committing them. However, if you want to do this in the designer, you can turn off that lock by going to Tools...Options...Designers..Table and Database Designers.. and unclick the "prevent saving changes that require table re-creation".
我强烈建议您使用 T-SQL 进行更改,或者至少在提交之前预览设计人员生成的脚本。但是,如果您想在设计器中执行此操作,您可以通过转到工具...选项...设计器...表和数据库设计器...关闭该锁定,然后取消单击“防止保存需要重新表的更改”创建”。
That lock is on by default for a reason; it keeps you from committing some change that is obfuscated by the designer.
由于某种原因,该锁默认处于开启状态;它可以防止您提交一些被设计师混淆的更改。
EDIT: As noted in the comment below, you can't preview the changes unless you disable the lock. My point is that if you want to use the table-designer to work on a table with this feature disabled, you should be sure to always preview the changes before committing them. In short, options are:
编辑:如以下评论中所述,除非禁用锁定,否则无法预览更改。我的观点是,如果您想使用 table-designer 在禁用此功能的表上工作,您应该确保在提交更改之前始终预览更改。简而言之,选项是:
- BEST PROCESS: Use T-SQL
- NOT GREAT: Disable the lock, use Table Designer, and ALWAYS preview changes
- CRAZY TALK: Click some buttons.
- 最佳过程:使用 T-SQL
- 不是很好:禁用锁定,使用表设计器,并始终预览更改
- 疯狂谈话:点击一些按钮。
回答by user3646967
To change the Prevent saving changes that require the table re-creation option, follow these steps: Open SQL Server Management Studio (SSMS). On the Tools menu, click Options. In the navigation pane of the Options window, click Designers. Select or clear the Prevent saving changes that require the table re-creation check box, and then click OK.
若要更改阻止保存需要重新创建表的更改选项,请按照下列步骤操作: 打开 SQL Server Management Studio (SSMS)。在工具菜单上,单击选项。在选项窗口的导航窗格中,单击设计器。选中或清除阻止保存需要重新创建表的更改复选框,然后单击确定。
回答by ThePG
Just to add to what Stuart Ainsworth said, you can right-click in the SSMS designer window and select the 'Generate Change Script...' option after you have edited to generate and review the script created by the designer for your changes.
补充一下 Stuart Ainsworth 所说的内容,您可以在 SSMS 设计器窗口中右键单击并在编辑后选择“生成更改脚本...”选项,以生成和查看设计器为您的更改创建的脚本。