2017-05-04 3 views
0

私はそれがエラーを取得している非主キー列に表パーティションを作成しようとしています:パーティションSQL Serverの非主キー列の表

パーティションを作成する方法
CREATE PARTITION FUNCTION PartitionFuncByCntry (int) AS RANGE RIGHT 
FOR VALUES ('10','11','12','15'); 

CREATE PARTITION SCHEME PartitionSchemeByCntry AS PARTITION 
PartitionFuncByCntry TO 
([PRIMARY],[PRIMARY],[PRIMARY],[PRIMARY],[PRIMARY]); 

CREATE TABLE tblPartitionByCntry(memberId int PRIMARY KEY 
identity(1,1), cntryId int, txt1 varchar(100), txt2 varchar(100), txt3 
varchar(100), txt4 varchar(100)) ON PartitionSchemeByCntry(cntryId); 

Msg 1908, Level 16, State 1, Line 16 Column 'cntryId' is partitioning column of the index 'PK__tblPartitionByCn__0880433F'. Partition columns for a unique index must be a subset of the index key. Msg 1750, Level 16, State 0, Line 16 Could not create constraint. See previous errors.

非プライマリキーで?

答えて

0

このように、主キーを使用して作成したテーブルにパーティションスキームを適用するように作成してみてください。 PartitionSchemeByCntry

CREATE TABLE [DBO].[RowTrip] 
(
    [id] [int] NOT NULL, 
    [Season] [int] NOT NULL, 
    [Distance] [decimal] not null 
    CONSTRAINT [PK_TBL_ROWTRIP] PRIMARY KEY CLUSTERED (id ASC) 
) 
GO 

CREATE INDEX [CI_ROWTRIP_BY_SEASON] ON [dbo].[RowerTrip] 
(
    [Season] 
) ON [PS_BY_SEASON]([Season]) 

PS_BY_SEASONはあなたです

関連する問題