簡體   English   中英

在SQL Server 2012中創建具有日期作為范圍分區的表

[英]Creating a table with date as range partition in SQL Server 2012

我是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)); 

提前致謝

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.

您可以在MSDN上找到代碼示例。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM