标签:
1,创建实例数据
-- create parition function CREATE PARTITION FUNCTION pf_int_Left (int) AS RANGE LEFT FOR VALUES (10,20); --create partition scheme CREATE PARTITION SCHEME PS_int_Left AS PARTITION pf_int_Left TO ([primary], [primary], [primary]); --create partitioned table create table dbo.dt_partition ( ID int, Code int ) on PS_int_Left (ID) --insert data into dbo.dt_partition insert into dbo.dt_partition ( ID, Code ) values(15,2)
创建 staging table,用于接收partition 2的数据
2,测试 nullability
--Create staging table create table dbo.dt_SwitchStaging ( ID int not null, Code int ) on [primary]
switch data
--swith partition 2 to staging table alter table dbo.dt_partition switch partition 2 to dbo.dt_SwitchStaging
Msg 4985, Level 16, State 1, Line 2
ALTER TABLE SWITCH statement failed because column ‘ID‘ does not have the same nullability attribute in tables ‘DB_Study.dbo.dt_partition‘ and ‘DB_Study.dbo.dt_SwitchStaging‘.
3,测试数据类型的兼容性
alter table dbo.dt_SwitchStaging alter column ID bigint null
switch data
--swith partition 2 to staging table
alter table dbo.dt_partition
switch partition 2
to dbo.dt_SwitchStaging
Msg 4944, Level 16, State 1, Line 2
ALTER TABLE SWITCH statement failed because column ‘ID‘ has data type int in source table ‘DB_Study.dbo.dt_partition‘ which is different from its type bigint in target table ‘DB_Study.dbo.dt_SwitchStaging‘.
Partition table的switch条件1:结构相同(类型,nullability)
标签:
原文地址:http://www.cnblogs.com/ljhdo/p/5040150.html