Table 在 Azure 中出现聚簇索引错误

Clustered Index Error in Azure for a Table that Has a Clustered Index

我是 运行 SQL Azure 上的这个命令。

DELETE FROM dbo.Users

我遇到了这个错误。

Msg 40054, Level 16, State 1, Line 1
Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.

然后我尝试创建聚簇索引。

CREATE UNIQUE CLUSTERED INDEX Idx_Users ON dbo.Users(Id);

我收到这个错误。

Msg 1902, Level 16, State 3, Line 4
Cannot create more than one clustered index on table 'dbo.Users'. Drop the existing clustered index 'PK_dbo.Users' before creating another.

我是否有聚簇索引?

我有一个类似的问题,我无法从 table.

中删除记录

阅读此 post、SQL Azure not recognizing my clustered Index 后,与您的 post 配对后,我通过 MSSMS 在 Security_User table 上检查了依赖项; 0-n 关系 table、Security_UserHistory 对此 table 有 FK 引用。此引用未编入索引并且(奇怪的是)触发了相关错误。

在 FK-table Security_UserHistory 引用 PK-table Security_User 应用 CLUSTERED INDEX 后,问题解决了。

我希望 Microsoft 在错误消息中添加一些清晰度,因为它表明问题出在您要从中删除行的 table。