我已经创建了一个分区函数,但我无法将它应用到表中。我不确定我哪里出错了。
这是我的分区函数:
CREATE PARTITION FUNCTION StaticDateMonthPartition (int)
AS RANGE left
FOR VALUES (
20120301,
20120401,
20120501,
20120601,
20120701,
20120801,
20120901,
20121001,
20121101,
20121201,
20130101,
20130201
)
试图应用于此表:
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[partition_OLAP_Fact_vvv]') AND type in (N'U'))
DROP TABLE [dbo].[partition_OLAP_Fact_vvv]
GO
CREATE TABLE [dbo].[partition_OLAP_Fact_vvv]
(
FFFFactvvvId bigint,
CORStaticDateId int,
CORVersionvvvId bigint,
vvvCount tinyint,
UPB decimal(18, 2)
) ON CORStaticDateMonthPartition ([CORStaticDateId])
但是当我尝试执行表脚本时,我得到了这个错误:
Invalid partition scheme 'CORStaticDateMonthPartition' specified
请帮忙。
用步骤重新发布我的代码
Pinal的教程很棒!这是一个快速的总结
为每个分区添加文件组
Alter Database [database] Add FileGroup partition_201207
创建分区函数
CREATE PARTITION FUNCTION Partition_Range_CORStaticMonth(int) AS RANGE left FOR VALUES (20120301)
创建分区方案
CREATE PARTITION SCHEME Partition_Scheme_CORStaticMonth AS PARTITION Partition_Range_CORStaticMonth TO (FFF_Fact_vvv_201203)
将文件添加到文件组
ALTER DATABASE [database] ADD FILE( NAME = N'FFF_Fact_vvv_201203', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\FFF_Fact_vvv_201203.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) TO FILEGROUP [FFF_Fact_vvv_201203]
应用分区方案的构建表
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[partition_Table]') AND type in (N'U')) DROP TABLE [dbo].[partition_Table] GO CREATE TABLE [dbo].[partition_Table] ( CORStaticDateId int ) ON Partition_Scheme_CORStaticMonth ([CORStaticDateId])