Set Statistics io On -- 打开查看IO
-- 1.将数据归档简单操作,按年分,可以分成若干个表
select * into Log2011
from Log
where StartTime between '2011-1-1' and '2011-12-31'
-- 2.为这些表创建一个约束
alter table log2011
add constraint CK_2011 check (StartTime between '2011-1-1' and '2011-12-31')
-- 3.为这些表建立一个视图
-- 这里可以测试,如果用约束和不用约束差别很大
ALTER view V_AllDocLog
as
select * from log2009
union all
select * from Log2010
union all
select * from Log2011
go
-- 1.将数据归档简单操作,按年分,可以分成若干个表
select * into Log2011
from Log
where StartTime between '2011-1-1' and '2011-12-31'
-- 2.为这些表创建一个约束
alter table log2011
add constraint CK_2011 check (StartTime between '2011-1-1' and '2011-12-31')
-- 3.为这些表建立一个视图
-- 这里可以测试,如果用约束和不用约束差别很大
ALTER view V_AllDocLog
as
select * from log2009
union all
select * from Log2010
union all
select * from Log2011
go