在 SQL Server Management Studio 中编辑表后保存更改
如果我想保存之前保存在 SQL Server Management Studio 中的表中的任何更改(表中不存在数据),我会收到一条错误消息:
不允许保存更改。您所做的更改需要 以下表格将被删除并重新创建。你要么做了 对表的更改无法重新创建或启用该选项 防止保存需要重新创建表的更改。
什么可以防止表格被轻易编辑?或者,SQL Server Management Studio 是否需要重新创建表进行编辑?它是什么 - 这个“选项阻止保存更改”?
If I want to save any changes in a table, previously saved in SQL Server Management Studio (no data in table present) I get an error message:
Saving changes is not permitted. The changes you have made require the
following tables to be dropped and re-created. You have either made
changes to a table that can't be re-created or enabled the option
Prevent saving changes that require the table to be re-created.
What can prevent the table to be easily edited? Or, is it the usual way for SQL Server Management Studio to require re-creating table for editing? What is it - this "option Prevent saving changes"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您应该停止以这种方式编辑数据,而不是取消选中该框(一个糟糕的解决方案)。如果必须更改数据,请使用脚本进行更改,以便您可以轻松地将其移植到生产环境中,并使其处于源代码控制之下。这也使得在生产被推送到开发人员之后更容易刷新测试更改,使开发人员能够处理更新的数据。
Rather than unchecking the box (a poor solution), you should STOP editing data that way. If data must be changed, then do it with a script, so that you can easily port it to production and so that it is under source control. This also makes it easier to refresh testing changes after production has been pushed down to dev to enable developers to be working against fresher data.
您可以在 SQL Server Management Studio 的表编辑器中非常轻松、直观地进行许多更改,但实际上需要 SSMS 在后台删除表并从头开始重新创建。即使像对列重新排序这样简单的事情也无法用标准 SQL DDL 语句来表达 - SSMS 所能做的就是删除并重新创建表。
此操作可能 a) 在大型表上非常耗时,或者 b) 甚至可能因各种原因(例如 FK 约束等)而失败。因此,SQL Server 2008 中的 SSMS 引入了其他答案已经确定的新选项。
乍一看,阻止此类更改似乎违反直觉 - 而且这对开发服务器来说肯定是一个麻烦。但在生产服务器上,此选项及其防止此类更改的默认值成为潜在的救星!
Many changes you can make very easily and visually in the table editor in SQL Server Management Studio actually require SSMS to drop the table in the background and re-create it from scratch. Even simple things like reordering the columns cannot be expressed in standard SQL DDL statement - all SSMS can do is drop and recreate the table.
This operation can be a) very time consuming on a large table, or b) might even fail for various reasons (like FK constraints and stuff). Therefore, SSMS in SQL Server 2008 introduced that new option the other answers have already identified.
It might seem counter-intuitive at first to prevent such changes - and it's certainly a nuisance on a dev server. But on a production server, this option and its default value of preventing such changes becomes a potential life-saver!
重现问题的步骤
Steps to reproduce the problem
进入工具->选项->设计师->取消选中“防止保存需要重新创建表的更改”。瞧。
发生这种情况是因为有时需要删除并重新创建表才能更改某些内容。这可能需要一段时间,因为必须将所有数据复制到临时表,然后重新插入到新表中。由于 SQL Server 默认情况下不信任您,因此您需要说“好吧,我知道我在做什么,现在让我做我的工作。”
Go into Tools -> Options -> Designers-> Uncheck "Prevent saving changes that require table re-creation". Voila.
That happens because sometimes it is necessary to drop and recreate a table in order to change something. This can take a while, since all data must be copied to a temp table and then re-inserted in the new table. Since SQL Server by default doesn't trust you, you need to say "OK, I know what I'm doing, now let me do my work."
工具|选项|设计师|表和数据库设计器
取消选中“防止保存需要重新创建表的更改”选项。
Tools | Options | Designers | Table and Database Designers
Uncheck the option "Prevent saving changes that require table re-creation".
要解决此问题,请使用 SQL 语句更改表的元数据结构。
当启用“防止保存需要重新创建表的更改”选项时,会出现此问题。
来源:尝试在 SQL Server 2008 中保存表时出现错误消息:“不允许保存更改”
To work around this problem, use SQL statements to make the changes to the metadata structure of a table.
This problem occurs when "Prevent saving changes that require table re-creation" option is enabled.
Source: Error message when you try to save a table in SQL Server 2008: "Saving changes is not permitted"
转到 SSMS 并尝试此
菜单>>工具>>选项>>设计师>>取消选中“防止保存需要重新创建表的更改”。
对此有一个很好的解释:
http:// blog.sqlauthority.com/2009/05/18/sql-server-fix-management-studio-error- saving-changes-in-not-permission-the-changes-you-have-made-require-the-following-要删除并重新创建的表,您对选项卡进行了更改/
GO to SSMS and try this
Menu >> Tools >> Options >> Designers >> Uncheck “Prevent Saving changes that require table re-creation”.
Here is a very good explanation on this:
http://blog.sqlauthority.com/2009/05/18/sql-server-fix-management-studio-error-saving-changes-in-not-permitted-the-changes-you-have-made-require-the-following-tables-to-be-dropped-and-re-created-you-have-either-made-changes-to-a-tab/