sql - Azure 中具有聚集索引的表出现聚集索引错误

标签 sql azure azure-sql-database

我正在 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.

我有没有聚集索引?

最佳答案

我遇到了类似的问题,无法从表中删除记录。

读完这篇文章后,SQL Azure not recognizing my clustered Index ,与您的帖子配对,我通过 MSSMS 检查了我的 Security_User 表上的依赖关系; 0-n 关系表 Security_UserHistory 具有对此表的 FK 引用。该引用未编入索引,并且(奇怪的是)触发了相关错误。

将聚集索引应用于引用 PK 表 Security_User 的 FK 表 Security_UserHistory 后,问题得到解决。

enter image description here

我希望 Microsoft 能够在错误消息中添加一些说明,因为它表明问题出在您要从中删除行的表上。

关于sql - Azure 中具有聚集索引的表出现聚集索引错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29874250/

相关文章:

php - mysql_query() 函数的 mysql 查询错误

c# - AuthenticationContext 不包含 AcquireToken 定义?

azure - 应用程序网关 request_routing_rules 不存在

sql - Azure SQL 数据库与 VM 上的 Azure SQL

java - 已安装 JDBC 驱动程序但出现异常

java - Hibernate 延迟初始化集合,带有 Oracle DB 提示

sql - 查询Oracle将日期间隔连接在一行中

ajax - Azure Web App不加载.json文件

entity-framework - MS SQL Azure 内存中的 Entity Framework

c# - 自动从azure函数获取结果