使用 2 列进行表分区 [英] Table partitioning using 2 columns

查看:81
本文介绍了使用 2 列进行表分区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于分区函数,是否可以使用 2 列而不是仅使用 1 列来对表进行分区?

考虑一个有 3 列的表格

<前>ID(整数,主键,日期(日期时间),数量(整数)

我想按 2 列对这个表进行分区:DateNum.

这是我使用 1 列(日期)对表进行分区的操作:

创建PARTITION FUNCTION PFN_MonthRange (datetime)作为值的剩余范围 ('2009-11-30 23:59:59:997','2009-12-31 23:59:59:997','2010-01-31 23:59:59:997','2010-28-02 23:59:59:997','2010-03-31 23:59:59:997')去

解决方案

坏消息: 必须在单个列上定义分区函数.

好消息:该单列可以是 持久计算列,它是您尝试分区的两列的组合.

Is it possible to partition a table using 2 columns instead of only 1 for the partition function?

Consider a table with 3 columns

    ID (int, primary key, 
    Date (datetime), 
    Num (int)

I want to partition this table by 2 columns: Date and Num.

This is what I do to partition a table using 1 column (date):

create PARTITION FUNCTION PFN_MonthRange (datetime)
AS
RANGE left FOR VALUES ('2009-11-30 23:59:59:997',
                       '2009-12-31 23:59:59:997',
                       '2010-01-31 23:59:59:997',
                       '2010-28-02 23:59:59:997',
                       '2010-03-31 23:59:59:997')
go

解决方案

Bad News: The partition function has to be defined on a single column.

Good News: That single column could be a persisted computed column that is a combination of the two columns you're trying to partition by.

这篇关于使用 2 列进行表分区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆