唯一索引的分区列必须是索引键的子集

时间:2015-12-16 01:50:16

标签: sql sql-server

我在PK上遇到此错误,但我无法弄清楚如何修复它。我也需要PK来与分区存储对齐。

  

专栏' SizedTime'是索引的分区列   ' PK_CDR_Inbound_1&#39 ;.唯一索引的分区列必须是a   索引键的子集。

ALTER TABLE [dbo].[CDR_Inbound]  
ADD  CONSTRAINT [PK_CDR_Inbound_1] 
PRIMARY KEY NONCLUSTERED 
(
    [UUID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)


GO

我需要这个PK而不是索引。另一个问题答案是索引。

1 个答案:

答案 0 :(得分:0)

我想通了

 ALTER TABLE [dbo].[CDR_Inbound]  
ADD  CONSTRAINT [PK_CDR_Inbound_1] 
PRIMARY KEY NONCLUSTERED 
(
    [UUID] ASC,
**Sizedtime**
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
**on cdr(sizedtime)**

只需要将分区键添加到PK,然后再添加ON语句