【问题标题】:SQL Server Table PartitionSQL Server 表分区
【发布时间】:2013-11-14 15:59:18
【问题描述】:

我有一个包含以下列的表格

ID (INT Primary Key)
RecordDate (DateTime non-unique)
Name (varchar)

我已根据字段RecordDate(每月)将表分区到不同的文件组。

现在,如何在不将字段与 RecordDate 组合的情况下向此分区方案添加主键 ID?

【问题讨论】:

标签: sql-server partitioning


【解决方案1】:

简短的回答是,如果您不想将您的分区列作为复合列包含在主键中,则您的主键不能被聚集。因此,在 RecordDate 的分区方案上创建一个聚集索引。然后,当您创建主键约束时,将其设置为非集群。

请注意this can degrade performance and cause memory contention,一般不推荐。

【讨论】:

  • 我已尝试将 ID 创建为非集群。 ALTER TABLE dbo.PartitionTable WITH CHECK ADD CONSTRAINT PK_Container PRIMARY KEY NONCLUSTERED (ID) ON PartitionTablePrSc(RecordDate); GO 我得到一个错误 Column 'RecordDate' is partitioning column of the index 'PK_Container'. Partition columns for a unique index must be a subset of the index key.
  • 我可以在主分区上创建非集群主键。这会减慢我的插入速度。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-09-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多