日期:2014-05-18  浏览次数:20637 次

为一张表创建分区表。
现在有一个表,有五个字段。
SQL code

CREATE TABLE [dbo].[Business_Book_Detail_TMP](
    [id] [bigint] IDENTITY(1,1) NOT NULL,
    [mobile] [bigint] NOT NULL,
    [bizcode] [varchar](50) NULL,
    [saledate] [datetime] NULL,
    [usermobile] [varchar](20) NULL,
 CONSTRAINT [PK_Business_Book_Detail_TMP] PRIMARY KEY NONCLUSTERED 
(
    [id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
)


 然后 还取模[mobile]这个字段创建分区表。 
  没弄过分区表 求助各位了。

------解决方案--------------------
SQL code
CREATE PARTITION FUNCTION myRangePF1 (int)
AS RANGE LEFT FOR VALUES (1, 100, 1000) ;
GO
CREATE PARTITION SCHEME myRangePS1
AS PARTITION myRangePF1
TO (test1fg, test2fg, test3fg, test4fg) ; --数据库文件组没有时全指定为主文件组[PRIMARY]
GO

CREATE TABLE [dbo].[Business_Book_Detail_TMP](
    [id] [bigint] IDENTITY(1,1) NOT NULL,
    [mobile] [bigint] NOT NULL,
    [bizcode] [varchar](50) NULL,
    [saledate] [datetime] NULL,
    [usermobile] [varchar](20) NULL,
 CONSTRAINT [PK_Business_Book_Detail_TMP] PRIMARY KEY NONCLUSTERED 
(
    [id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON myRangePS1 ([id]))

------解决方案--------------------
http://blog.csdn.net/bg1jt/article/details/2070884