从表中的列中删除标识 [英] Remove Identity from a column in a table

查看:26
本文介绍了从表中的列中删除标识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 5GB 的表(将近 5 亿行),我们想删除其中一列的标识属性,但是当我们尝试通过 SSMS 执行此操作时 - 它超时了.

We have a 5GB table (nearly 500 million rows) and we want to remove the identity property on one of the column, but when we try to do this through SSMS - it times out.

这可以通过 T-SQL 完成吗?

Can this be done through T-SQL?

推荐答案

IDENTITY 规范一旦设置就无法删除.

You cannot remove an IDENTITY specification once set.

要删除整列:

ALTER TABLE yourTable
DROP COLUMN yourCOlumn;

有关ALTER TABLE的信息

如果您需要保留数据,但删除 IDENTITY 列,则需要:

If you need to keep the data, but remove the IDENTITY column, you will need to:

  • 创建一个新列
  • 将数据从现有的 IDENTITY 列转移到新列
  • 删除现有的 IDENTITY 列.
  • 将新列重命名为原始列名

这篇关于从表中的列中删除标识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆