SQL Server 2005 按外部引用数据对表进行分区
有没有一种规范的方法通过引用数据到另一个表来对表进行分区?
例如
timetable
id
datetime
bigtable
id
timetable_id -- foreign key
.. other data ..
我想按时间表中的日期时间对bigtable进行分区。谢谢。
is there a canonical way to partition a table by referenced data to another table?
for example
timetable
id
datetime
bigtable
id
timetable_id -- foreign key
.. other data ..
i want to partition bigtable by the datetime in timetable. thankx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如此处所述,他分区列必须是表上所有唯一索引的一部分,其中包括主键。
我认为您在这里唯一的选择是将
timetable.datetime
列非规范化为bigtable
,以便该列可用于分区。As noted here, he partitioning column must be a part of all unique indexes on the table, which would include your primary key.
I think your only choice here would be to denormalize the
timetable.datetime
column intobigtable
so that the column is available for partitioning.分区键必须是正在分区的表的列。如果
timetable
中的id
和datetime
之间存在关联,那么您可以按该 id 进行分区:然后是分区范围 (2009-10-01 , 2009-10-31), (2009-11-01, 2009-11-30) 等可以用
id
值表示:(1,31), (32,62), ...但是,这要求id
值的排名与datetime
值的排名完全匹配。如果您没有这种关联,则必须移动bigtable
中的datetime
列,或者重新排列您的id
以便它们相互关联他是日期时间
。Partitioning key must be a column of the table being partitioned. If you have a correlation between
id
anddatetime
intimetable
then you can partition by that id:then the partitioning ranges (2009-10-01, 2009-10-31), (2009-11-01, 2009-11-30) etc can be expressed in terms of
id
values: (1,31), (32,62), ... However, this requires that the rank of theid
values matches exactly the rank of thedatetime
values. If you don't have this correlation, then you must either move thedatetime
column in thebigtable
, or rearrange yourid
so that they correlate wqitht hedatetime
.