【问题标题】:Creating a table with date as range partition in SQL Server 2012在 SQL Server 2012 中创建以日期为范围分区的表
【发布时间】:2014-04-15 04:04:36
【问题描述】:

我是 SQL Server 编码的新手。请告诉我如何在 SQL Server 中创建具有日期范围分区的表

teradata 中的类似语法如下(创建一个表,将订单日期作为 2012 年的范围分区,每天作为单个分区)

CREATE TABLE ORDER_DATA (   
   ORDER_NUM INTEGER NOT NULL 
   ,CUST_NUM INTEGER 
   ,ORDER_DATE DATE 
   ,ORDER_TOT DECIMAL(10,2) 
) 
PRIMARY INDEX(ORDER_NUM) 
PARTITION BY (RANGE_N ( ORDER_DATE BETWEEN DATE ‘2012-01-01’ AND DATE 2012-12-31 EACH INTERVAL ‘1’ DAY)); 

提前致谢

【问题讨论】:

    标签: sql sql-server sql-server-2012 teradata


    【解决方案1】:

    创建分区表的过程在MSDN上描述如下:

    Creating a partitioned table or index typically happens in four parts: 1. Create a filegroup or filegroups and corresponding files that will hold the partitions specified by the partition scheme. 2. Create a partition function that maps the rows of a table or index into partitions based on the values of a specified column. 3. Create a partition scheme that maps the partitions of a partitioned table or index to the new filegroups. 4. Create or modify a table or index and specify the partition scheme as the storage location.

    您可以找到代码示例on MSDN

    【讨论】:

    • 嗨,shree,您能否包括我的查询的总语法转换
    • @user3534342 我不确定这会增加多少价值,因为即使在这个答案中我已经在参考官方文档。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-18
    • 1970-01-01
    • 2013-12-15
    • 2019-03-09
    • 1970-01-01
    相关资源
    最近更新 更多