Sql Server“不允许保存更改”错误►防止保存需要重新创建表的更改

发布于 2024-11-26 09:17:57 字数 276 浏览 4 评论 0原文

当我在 SQL Server 中创建表并保存它时,如果我尝试编辑表设计(例如将列类型从 int 更改为 real),则会收到以下错误:

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

为什么我必须重新创建表?我只想将数据类型从 smallint 更改为 real

桌子是空的,我到现在都没用过。

When I create a table in SQL Server and save it, if I try to edit the table design, like change a column type from int to real, I get this error:

Saving changes is not permitted. The change you have made requires the following table to be dropped and re-created. You have either made changes to a table that can't be recreated or enabled the option prevent saving changes that require the table to be re-created.

Why do I have to re-create the table? I just want to change a data type from smallint to real.

The table is empty, and I didn't use it until now.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(15

山川志 2024-12-03 09:17:57

来自 MSDN 上的“保存(不允许)”对话框

保存(不允许)对话框警告您保存更改
不允许,因为您所做的更改需要列出的
要删除并重新创建的表。

以下操作可能需要重新创建表:

  • 在表格中间添加新列
  • 删除一列
  • 更改列的可为空性
  • 更改列的顺序
  • 更改列的数据类型<<<<

要更改此选项,请在工具菜单上单击选项,展开
设计器,然后单击表和数据库设计器
选择或清除防止保存需要表的更改
重新创建
复选框。

参见
Colt Kwong 博客条目:
SQL 2008 Management Studio 中不允许保存更改

From Save (Not Permitted) Dialog Box on 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.

See Also
Colt Kwong Blog Entry:
Saving changes is not permitted in SQL 2008 Management Studio

我只土不豪 2024-12-03 09:17:57

如果您使用 SSMS:

转到菜单工具>>选项>>设计器并取消选中阻止保存需要重新创建表的更改

If you are using SSMS:

Go to the menu Tools >> Options >> Designers and uncheck Prevent Saving changes that require table re-creation

琉璃繁缕 2024-12-03 09:17:57

防止保存需要重新创建表的更改

快速点击五次

防止保存需要通过五次单击重新创建表的更改

  1. 工具
  2. 选项
  3. 设计师
  4. 防止保存需要重新创建表的更改
  5. 好的

保存后,重复该过程以重新勾选该框。这可以防止意外数据丢失。

进一步说明

  • 默认情况下,SQL Server Management Studio 会阻止删除表,因为当删除表时,其数据内容就会丢失。*

  • 在表设计视图中更改列的数据类型时,保存更改时,数据库会在内部删除表,然后重新创建一个新表。< /p>

*您的具体情况不会造成任何后果,因为您的桌子是空的。我提供此解释完全是为了提高您对该过程的理解。

Prevent saving changes that require table re-creation

Five swift clicks

Prevent saving changes that require table re-creation in five clicks

  1. Tools
  2. Options
  3. Designers
  4. Prevent saving changes that require table re-creation
  5. OK.

After saving, repeat the proceudure to re-tick the box. This safe-guards against accidental data loss.

Further explanation

  • By default SQL Server Management Studio prevents the dropping of tables, because when a table is dropped its data contents are lost.*

  • When altering a column's datatype in the table Design view, when saving the changes the database drops the table internally and then re-creates a new one.

*Your specific circumstances will not pose a consequence since your table is empty. I provide this explanation entirely to improve your understanding of the procedure.

眉黛浅 2024-12-03 09:17:57

这可以在 Microsoft SQL Server 中轻松更改。

  1. 打开 Microsoft SQL Server Management Studio 2008
  2. 点击“工具”菜单
  3. 点击选项
  4. 选择设计师
  5. 取消选中“防止保存需要重新创建表的更改”
  6. 点击“确定”

在此处输入图像描述

This can be changed easily in Microsoft SQL Server.

  1. Open Microsoft SQL Server Management Studio 2008
  2. Click Tools menu
  3. Click Options
  4. Select Designers
  5. Uncheck "Prevent saving changes that require table re-creation"
  6. Click OK

enter image description here

愿得七秒忆 2024-12-03 09:17:57

要更改阻止保存需要重新创建表的更改选项,请按照下列步骤操作:

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

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

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

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

输入图像描述这里

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.

Note: If you disable this option, you are not warned when you save the table that the changes that you made have changed the metadata structure of the table. In this case, data loss may occur when you save the table.

enter image description here

偏闹i 2024-12-03 09:17:57

这是非常简单的设置问题,按照以下步骤可以在 5 秒内修复

为了允许您在更改表后保存更改,请按照以下步骤进行 SQL 设置:

  1. 打开 Microsoft SQL Server Management Studio 2008
  2. 单击“工具”菜单选项,然后单击“选项”
  3. 选择设计器
  4. 取消选中“防止保存需要重新创建表的更改”选项
  5. 单击“确定”
  6. 尝试更改表
  7. 您的更改将根据需要执行

It is very easy and simple setting problem that can be fixed in 5 seconds by following these steps

To allow you to save changes after you alter table, Please follow these steps for your sql setting:

  1. Open Microsoft SQL Server Management Studio 2008
  2. Click Tools menu options, then click Options
  3. Select Designers
  4. Uncheck "prevent saving changes that require table re-creation" option
  5. Click OK
  6. Try to alter your table
  7. Your changes will performed as desired
请持续率性 2024-12-03 09:17:57

进入顶部菜单的工具
从下拉列表中选择选项。现在,您会在左侧菜单块上弹出一个选择设计器选项的窗口。取消选中防止保存需要重新创建表的更改选项。单击“确定”按钮。

Go on Tool located at top menu.
Choose options from dropdown.You have a popup now select Designers option located on left hand block of menus. Uncheck the option Prevent saving changes that require table re-creation. Click on OK Button.

離人涙 2024-12-03 09:17:57

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

SQL Server 2012 示例:

在此处输入图像描述

Un-tick the Prevent saving changes that require table re-creation box from Tools ► Options ► Designers tab.

SQL Server 2012 example:

enter image description here

陈独秀 2024-12-03 09:17:57

复制自此链接
... 重要提示 我们强烈建议您不要通过关闭“防止保存需要重新创建表的更改”选项来解决此问题。有关关闭此选项的风险的更多信息,请参阅“更多信息”部分''

" ...要解决此问题,请使用 Transact-SQL 语句更改表的元数据结构。有关其他信息,请参阅 SQL Server 联机丛书中的以下主题

例如,要更改名为 MyTable 的表中 datetime 类型的 MyDate 列以接受 NULL 值,您可以使用:

alter table MyTable alter columns MyDate7 datetime NULL "

Copied from this link
" ... Important We strongly recommend that you do not work around this problem by turning off the Prevent saving changes that require table re-creation option. For more information about the risks of turning off this option, see the "More information" section. ''

" ...To work around this problem, use Transact-SQL statements to make the changes to the metadata structure of a table. For additional information refer to the following topic in SQL Server Books Online

For example, to change MyDate column of type datetime in at table called MyTable to accept NULL values you can use:

alter table MyTable alter column MyDate7 datetime NULL "

羞稚 2024-12-03 09:17:57

以防万一这里有人也没有注意(像我一样):

对于 Microsoft SQL Server 2012,在选项对话框中,有一个偷偷摸摸的小复选框,它显然隐藏了所有其他设置。虽然我不得不说我一直很想念那个小怪物!

之后,您可以继续执行步骤,设计者,取消选中防止保存等等等等...

sneaky_check_box_in_option

And just in case someone here is also not paying attention (like me):

For Microsoft SQL Server 2012, in the options dialogue box, there is a sneaky little check box that APPARENTLY hides all other setting. Although I got to say that I have missed that little monster all this time!!!

After that, you may proceed with the steps, designer, uncheck prevent saving blah blah blah...

sneaky_check_box_in_option

小帐篷 2024-12-03 09:17:57

1)打开顶部的工具。
2) 从选项列表中选择选项。
3)现在出现弹出窗口,您现在可以从左侧的菜单列表中选择设计器选项。
4) 现在需要取消选中需要重新创建表的保存更改。 现在点击“确定”。

1) Open tool which is on top.
2) Choose options from Picklist.
3) Now Comes the popup and you can now select designers option from the list of menus on the left side.
4) Now prevent saving changes need to be unchecked that needed table re-creation. Now Click OK.

皇甫轩 2024-12-03 09:17:57

从“工具”菜单中,单击“选项”,从侧面菜单中选择“设计器”,然后取消选中“防止可能导致重新创建表的更改”。然后保存更改

From the Tools menu, click on Options, select Designers from the side menu and untick prevent changes that can lead to recreation of a table. Then save the changes

聽兲甴掵 2024-12-03 09:17:57

如果您使用 sql server Management studio,请转到
工具>>选项>>设计者并取消选中“防止保存需要重新创建表的更改”
它对我有用

If you use sql server Management studio go to
Tools >> Options >> Designers and uncheck “Prevent Saving changes that require table re-creation”
It works with me

这个俗人 2024-12-03 09:17:57

如果您在列表中看不到“防止保存需要重新创建表的更改”
图片

您需要启用更改跟踪。

  • 右键单击您的数据库,然后单击属性
  • 单击更改跟踪并启用
  • Go Tools ->选项->再次设计并取消选中它。

If you can not see the "Prevent saving changes that required table re-creation" in list like that
The image

You need to enable change tracking.

  • Right click on your database and click Properties
  • Click change tracking and make it enable
  • Go Tools -> Options -> Designer again and uncheck it.
锦爱 2024-12-03 09:17:57

实际上,您被 SSMS 阻止,而不是 SQL Server。

解决方案是更改 SSMS 的设置或使用 SQL 查询。

使用 SQL 查询您可以自由地进行更新。
例如,您想向表中添加新列,您可以这样做:

ALTER TABLE 客户添加电子邮件 varchar(255) NOT NULL DEFAULT 'OK';

其他选项是更改 SSMS 设置。请参考其他答案,很多人已经解释过了。

Actually, You are blocked by SSMS not the SQL Server.

The solution are either change setting of SSMS or use a SQL query.

Using SQL Query you could do the update freely.
Example you want to add a new column to a table, you could do like this :

ALTER TABLE Customers ADD Email varchar(255) NOT NULL DEFAULT 'OK';

Other option is changing SSMS setting. Please refer to other answer, as many has explain it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文