Dear all,
Let get into business, the partitions on sql server is very different with that on oracle.
I do not want to speak too much, Here is an example.
At beginning, we should create a partition function
CREATE PARTITION FUNCTION [PF_DATETIME_M_TEST](datetime) AS RANGE RIGHT FOR VALUES (N'2013-08-01T00:00:00.000',N'2013-09-01T00:00:00.000', N'2013-10-01T00:00:00.000', N'2013-11-01T00:00:00.000', N'2013-12-01T00:00:00.000', N'2014-01-01T00:00:00.000', N'2014-02-01T00:00:00.000', N'2014-03-01T00:00:00.000', N'2014-04-01T00:00:00.000', N'2014-05-01T00:00:00.000', N'2014-06-01T00:00:00.000', N'2014-07-01T00:00:00.000', N'2014-08-01T00:00:00.000', N'2014-09-01T00:00:00.000', N'2014-10-01T00:00:00.000', N'2014-11-01T00:00:00.000', N'2014-12-01T00:00:00.000', N'2015-01-01T00:00:00.000', N'2015-02-01T00:00:00.000', N'2015-03-01T00:00:00.000', N'2015-04-01T00:00:00.000', N'2015-05-01T00:00:00.000', N'2015-06-01T00:00:00.000', N'2015-07-01T00:00:00.000', N'2015-08-01T00:00:00.000', N'2015-09-01T00:00:00.000', N'2015-10-01T00:00:00.000', N'2015-11-01T00:00:00.000', N'2015-12-01T00:00:00.000', N'2016-01-01T00:00:00.000')
You seem, the partittion function is used to define partition key range,
Next we need to create partittion schema
CREATE PARTITION SCHEME [PS_DATETIME_M_TEST] AS PARTITION [PF_DATETIME_M_TEST] TO ([XXXXFG_initial],[XXXXFG_201308], [XXXXFG_201309], [XXXXFG_201310], [XXXXFG_201311], [XXXXFG_201312], [XXXXFG_201401], [XXXXFG_201402], [XXXXFG_201403], [XXXXFG_201404], [XXXXFG_201405], [XXXXFG_201406], [XXXXFG_201407], [XXXXFG_201408], [XXXXFG_201409], [XXXXFG_201410], [XXXXFG_201411], [XXXXFG_201412], [XXXXFG_201501], [XXXXFG_201502], [XXXXFG_201503], [XXXXFG_201504], [XXXXFG_201505], [XXXXFG_201506], [XXXXFG_201507], [XXXXFG_201508], [XXXXFG_201509], [XXXXFG_201510], [XXXXFG_201511], [XXXXFG_201512], [XXXXFG_201601])
GO
the partititon schema is to tell database which rang locate on which place --- filegroup.
Then we can go for generating partititon now.
CREATE TABLE [dbo].[LAS_DATA_TEST](
[IDN] [numeric](19, 0) NOT NULL,
[RECORD_NO] [numeric](20, 0) NOT NULL,
[CREATE_DATE] [datetime] NOT NULL,
[RECORD_TYPE] [numeric](9, 0) NULL,
[FAULT_YPOS] [numeric](9, 2) NULL,
[FILE_NAME] [nvarchar](100) NULL,
[FILE_DIRECTORY] [nvarchar](50) NULL,
[FAULT_MARK] [nvarchar](50) NULL,
[CAMERA_NO] [nvarchar](4) NULL,
[FAULT_START_ZONE] [numeric](9, 2) NULL,
[FAULT_END_ZONE] [numeric](9, 2) NULL,
[FAULT_GROUP_NO] [numeric](9, 2) NULL,
[FAULT_RANK_NO] [numeric](9, 2) NULL,
[PERIOD_TERM] [numeric](9, 2) NULL,
[PERIOD_NO] [numeric](9, 2) NULL,
[FAULT_XPOS] [numeric](9, 2) NULL,
[FAULT_WIDTH] [numeric](9, 2) NULL,
[LINE_SPEED] [numeric](9, 2) NULL,
[AL_BOXW] [numeric](9, 2) NULL,
[AD_BOXW] [numeric](9, 2) NULL,
[BL_BOXW] [numeric](9, 2) NULL,
[BD_BOXW] [numeric](9, 2) NULL,
[CL_BOXW] [numeric](9, 2) NULL,
[CD_BOXW] [numeric](9, 2) NULL,
[DT_BOXW] [numeric](9, 2) NULL,
[ST_BOXW] [numeric](9, 2) NULL,
[DM_BOXW] [numeric](9, 2) NULL,
[AL_BOXL] [numeric](9, 2) NULL,
[AD_BOXL] [numeric](9, 2) NULL,
[BL_BOXL] [numeric](9, 2) NULL,
[BD_BOXL] [numeric](9, 2) NULL,
[CL_BOXL] [numeric](9, 2) NULL,
[CD_BOXL] [numeric](9, 2) NULL,
[DT_BOXL] [numeric](9, 2) NULL,
[ST_BOXL] [numeric](9, 2) NULL,
[DM_BOXL] [numeric](9, 2) NULL,
[AL_PEAK] [numeric](9, 2) NULL,
[AD_PEAK] [numeric](9, 2) NULL,
[BL_PEAK] [numeric](9, 2) NULL,
[BD_PEAK] [numeric](9, 2) NULL,
[CL_PEAK] [numeric](9, 2) NULL,
[CD_PEAK] [numeric](9, 2) NULL,
[DT_PEAK] [numeric](9, 2) NULL,
[ST_PEAK] [numeric](9, 2) NULL,
[DM_PEAK] [numeric](9, 2) NULL,
[AL_AREA] [numeric](9, 2) NULL,
[AD_AREA] [numeric](9, 2) NULL,
[BL_AREA] [numeric](9, 2) NULL,
[BD_AREA] [numeric](9, 2) NULL,
[CL_AREA] [numeric](9, 2) NULL,
[CD_AREA] [numeric](9, 2) NULL,
[DT_AREA] [numeric](9, 2) NULL,
[ST_AREA] [numeric](9, 2) NULL,
[DM_AREA] [numeric](9, 2) NULL,
[AL_RATE1] [numeric](9, 2) NULL,
[AD_RATE1] [numeric](9, 2) NULL,
[BL_RATE1] [numeric](9, 2) NULL,
[BD_RATE1] [numeric](9, 2) NULL,
[CL_RATE1] [numeric](9, 2) NULL,
[CD_RATE1] [numeric](9, 2) NULL,
[DT_RATE1] [numeric](9, 2) NULL,
[ST_RATE1] [numeric](9, 2) NULL,
[DM_RATE1] [numeric](9, 2) NULL,
[AL_RATE2] [numeric](9, 2) NULL,
[AD_RATE2] [numeric](9, 2) NULL,
[BL_RATE2] [numeric](9, 2) NULL,
[BD_RATE2] [numeric](9, 2) NULL,
[CL_RATE2] [numeric](9, 2) NULL,
[CD_RATE2] [numeric](9, 2) NULL,
[DT_RATE2] [numeric](9, 2) NULL,
[ST_RATE2] [numeric](9, 2) NULL,
[DM_RATE2] [numeric](9, 2) NULL,
[AL_RATE3] [numeric](9, 2) NULL,
[AD_RATE3] [numeric](9, 2) NULL,
[BL_RATE3] [numeric](9, 2) NULL,
[BD_RATE3] [numeric](9, 2) NULL,
[CL_RATE3] [numeric](9, 2) NULL,
[CD_RATE3] [numeric](9, 2) NULL,
[DT_RATE3] [numeric](9, 2) NULL,
[ST_RATE3] [numeric](9, 2) NULL,
[DM_RATE3] [numeric](9, 2) NULL,
[RESERVE3] [numeric](9, 2) NULL,
[RESERVE4] [numeric](9, 2) NULL,
[REMARK] [nvarchar](1000) NULL,
[INDEX_NO] [numeric](5, 0) NULL,
[DEFECT_TYPE] [nvarchar](50) NULL,
[MAX_SIZE] [numeric](9, 2) NULL,
[MIN_SIZE] [numeric](9, 2) NULL,
[F_R] [numeric](9, 2) NULL,
[UPDATE_DATE] [datetime] NULL,
[PVA_WIDTH_MAX] [numeric](9, 1) NULL,
[PVA_WIDTH_MIN] [numeric](9, 1) NULL,
[PEAK_AREA] [numeric](9, 3) NULL,
[GRADE] [nvarchar](100) NULL,
[FAULT_DETECT_SIZE] [numeric](9, 0) NULL,
[STRONG_SPOT_SIZE] [numeric](9, 0) NULL,
[STRONG_SPOT_FR] [numeric](19, 0) NULL,
[FAULT_EXCEPT_MAX] [numeric](9, 0) NULL,
[FAULT_EXCEPT_MIN] [numeric](9, 0) NULL,
[FAULT_EXCEPT_FR_MAX] [numeric](9, 0) NULL,
[FAULT_EXCEPT_FR_MIN] [numeric](9, 0) NULL,
[FAULT_DETECT_FR] [numeric](9, 0) NULL,
[IMG_FLAG] [nvarchar](1) NULL,
[IMG_SIZE_X] [numeric](9, 2) NULL,
[IMG_SIZE_Y] [numeric](9, 2) NULL,
[SERIES] [nvarchar](4) NULL,
[V_VALUE_TYPE] [nvarchar](32) NULL,
[V_VLAUE] [numeric](9, 2) NULL,
[IMG_DATA] [varbinary](max) NULL,
CONSTRAINT [LAS_DATA_TEST_PK] PRIMARY KEY CLUSTERED
(
[IDN] ASC,
[RECORD_NO] ASC,
[CREATE_DATE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON,DATA_COMPRESSION=PAGE)
)ON PS_DATETIME_M_TEST (CREATE_DATE);
GO
Comments