_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › PartitionSwitch

drop table p_test;
drop partition scheme ps_test
drop partition function pf_test
go

create partition function pf_test(date)
as range right
for values ('20101101', '20101102', '20101103')
go


create partition scheme ps_test
as partition pf_test
to ([primary],[primary],[primary],[primary])
go

create table dbo.p_test(dt date null)  
on ps_test(dt) 
go


insert p_test values('20101101');
insert p_test values('20101102');
insert p_test values('20101103');

/*
select * from p_test

2010-11-01
2010-11-02
2010-11-03
*/

--swich

drop table p_switch;
create table p_switch(dt date);
alter table p_switch add constraint ck1
check (dt >= '20101104' and dt is not null);

insert p_switch values('20101104');



alter partition scheme ps_test next used [primary];
alter partition function pf_test() split range('20101104');

alter table dbo.p_switch switch  to dbo.p_test 
partition 5; -- 襷讌襷 一覯

/*
--襷讌襷 一覯
select max(b.destination_id)
from sys.partition_schemes a
	inner join sys.destination_data_spaces b
		on a.data_space_id = b.partition_scheme_id
	inner join sys.data_spaces c
		on b.data_space_id = c.data_space_id
where a.name = 'ps_test'		
*/
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:53

覈 襷 螻 企Μ 襷 .