我创建了分区函数,但我无法将其应用于表格。我不确定我哪里出错了。
这是我的分区功能:
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's tutoral很棒!这是一个快速摘要
为每个分区添加文件组
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])
答案 0 :(得分:2)
答案 1 :(得分:0)
这只是一个命名问题,不应该:
) ON CORStaticDateMonthPartition ([CORStaticDateId])
是
) ON StaticDateMonthPartition ([CORStaticDateId])