关于SQL Server分区
分区方法
创建文件组
创建文件
创建分区函数
创建分区架构
同步数据到分区表
新同步一个数据源到分区表
判断是否存在分区
如果不是,创建分区,再同步数据
如果是,直接同步数据
创建分区(文件,文件组,pf,ps)
if not exists (select name from sys.data_spaces
where name='fg_test_201706')
alter database test add filegroup fg_test_201706
if not exists (select name from sys.database_files
where name='f_test_201706_1')
alter database test add file ( name = N'f_test_201706_1', filename = N'D:\MSSQL_DATA\ifc_etrade\\f_test_201706_1.ndf' , size = 30720kb , filegrowth = 10240kb ) to filegroup fg_test_201706
--可以一个文件组 对应 多个 数据文件 *.ndf
1 创建文件组 文件
1.1, 创建文件组 fg_tb207xxxx 每天一天 逻辑存在
1.2, 创建数据文件 f_tb201607xx 每天一天 物理存在
--20160101 - 20190101
2, 创建pf ps 最多1000个分区
create partition function pf_table(int) as range left for values (20160101, 20160102, 20160103, 20160104, 20160105, 20160106, 20160107);
--20160101 至 20180101
create partition scheme ps_table as partition pf_table to( FG_test20160101, FG_test20160102, FG_test20160103, FG_test20160104, FG_test20160105, FG_test20160106, FG_test20160107, FG_test20160108);
逻辑文件FG
物理文件 > 归属逻辑文件FG
分区函数边界
分区表关联 > 逻辑文件FG