【问题标题】:SQL Azure - Could not able to alter column typeSQL Azure - 无法更改列类型
【发布时间】:2011-11-25 07:36:57
【问题描述】:

今天我在 SQL Azure 门户中创建了一个新表,默认情况下有一个 Id INT 列。

Id ( int , PK , Not Null)

当我尝试将其更改为 BIGINT 时,它给了我以下错误:

An error was encountered while applying the changes.An exception occurred
while executing the Transact-SQL statement:
ALTER TABLE [dbo].[PerformanceData]
ALTER COLUMN [Id] BIGINT NOT NULL.
The object 'PrimaryKey_029c7a8d-e6b2-43b8-94f1-98fc5b0115e3' is dependent on
column 'Id'. ALTER TABLE ALTER COLUMN Id failed because one or more objects
access this column.

为什么会这样?

【问题讨论】:

    标签: sql-server-2008-r2 azure-sql-database


    【解决方案1】:

    看起来您要更改的列是主键列。您需要先删除相关约束。像这样的:ALTER TABLE [dbo].[PerformanceData] DROP CONSTRAINT Id

    【讨论】:

      猜你喜欢
      • 2020-03-08
      • 1970-01-01
      • 2021-12-01
      • 1970-01-01
      • 2012-07-15
      • 2014-06-07
      • 2020-11-22
      • 2021-09-14
      • 2018-08-25
      相关资源
      最近更新 更多