当我在SQL Server中创建一个表并保存它时,如果我尝试编辑表设计,比如将列类型从int更改为real,我会得到这个错误:

不允许保存更改。您所做的更改要求删除并重新创建下面的表。您对无法重新创建的表进行了更改,或者启用了防止保存需要重新创建表的更改的选项。

为什么我要重新创建表格?我只是想把一个数据类型从smallint改为real。

桌子是空的,我直到现在才用过。


当前回答

如果你正在使用SSMS:

进入“工具>>选项>>设计器”菜单,取消勾选“防止保存需要重新创建表的更改”

其他回答

要更改“防止保存需要重新创建表的更改”选项,请执行以下步骤:

打开SQL Server Management Studio (SSMS)。 在“工具”菜单上,单击“选项”。

在“选项”窗口的导航窗格中,单击“设计器”。

选中或清除“防止保存需要重新创建表的更改”复选框,然后单击“确定”。

注意:如果禁用此选项,则在保存表时不会警告您所做的更改更改了表的元数据结构。在这种情况下,在保存该表时可能会导致数据丢失。

取消选中“工具►选项►设计器”页签中的“防止保存需要重新创建表的更改”框。

SQL Server 2012示例:

如果你正在使用SSMS:

进入“工具>>选项>>设计器”菜单,取消勾选“防止保存需要重新创建表的更改”

点击位于顶部菜单的工具。 从下拉菜单中选择选项。你现在有一个弹出式选择设计师选项位于菜单的左手块。取消选中“防止保存需要重新创建表的更改”选项。点击OK按钮。

从MSDN上的保存(不允许)对话框:

The Save (Not Permitted) dialog box warns you that saving changes is not permitted because the changes you have made require the listed tables to be dropped and re-created. The following actions might require a table to be re-created: Adding a new column to the middle of the table Dropping a column Changing column nullability Changing the order of the columns Changing the data type of a column <<<< To change this option, on the Tools menu, click Options, expand Designers, and then click Table and Database Designers. Select or clear the Prevent saving changes that require the table to be re-created check box.

另请参阅 邝伟霆博客文章: 在SQL 2008 Management Studio中不允许保存更改