SQL Azure-无法更改列类型 [英] SQL Azure - Could not able to alter column type

查看:67
本文介绍了SQL Azure-无法更改列类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Today I created a new table in SQL Azure portal and by default there is an Id INT column.

Id ( int , PK , Not Null)

当我尝试将其更改为BIGINT时,出现以下错误:

When I tried to change it to BIGINT it gave me the following error:

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.

为什么会这样?

推荐答案

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

Looks like the column you are trying to alter is the primary key column. You need to drop related constraints first. Something like this:ALTER TABLE [dbo].[PerformanceData] DROP CONSTRAINT Id

这篇关于SQL Azure-无法更改列类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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