--创建新的文件组
ALTER DATABASE [KYK_B2C_Publish]
ADD FILEGROUP Partition_File_1
ALTER DATABASE [KYK_B2C_Publish]
ADD FILE
(
NAME='Test_Partition_Table_1',
FILENAME='E:\database\Testdatabase\Test_Partition_Table_1.ndf',
SIZE=200MB,
FILEGROWTH=10MB
) TO FILEGROUP Partition_File_1
--创建分区函数
IF EXISTS(SELECT * FROM SYS.PARTITION_Functions WHERE NAME ='RangeByPassportID_PartFuncion')
DROP PARTITION FUNCTION RangeByPassportID_PartFuncion
CREATE PARTITION FUNCTION RangeByPassportID_PartFuncion(bigint) AS RANGE LEFT FOR
VALUES(100000,200000,300000,400000)
--创建分区结构
IF EXISTS(SELECT * FROM SYS.PARTITION_SCHEMES WHERE NAME='Partition_Scheme_Test')
DROP PARTITION SCHEME Partition_Scheme_Test
CREATE PARTITION SCHEME [Partition_Scheme_Test] AS PARTITION [RangeByPassportID_PartFuncion]
TO ([Partition_File_1],[Partition_File_2],[Partition_File_3],[Partition_File_4],[Partition_File_5])
按顺序做就可以了,这就是表分区。
坐等楼主给分。呵呵
select a.name as [partition name],c.name as [filegroup name] from sys.partition_schemes a inner join sys.destination_data_spaces b on a.data_space_id=b.partition_scheme_id inner join sys.filegroups c on b.data_space_id=c.data_space_id
where a.name='Fs_WriteLog' order by b.partition_scheme_id,b.destination_id