Chinaunix首页 | 论坛 | 博客
  • 博客访问: 438134
  • 博文数量: 94
  • 博客积分: 3066
  • 博客等级: 中校
  • 技术积分: 908
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-25 17:10
文章分类

全部博文(94)

文章存档

2016年(3)

2015年(4)

2014年(1)

2013年(9)

2012年(8)

2011年(1)

2010年(8)

2009年(4)

2008年(2)

2007年(6)

2006年(48)

我的朋友

分类: 数据库开发技术

2012-07-04 13:29:15

 
CREATE PARTITION FUNCTION OneYearDateRangePFN(datetime)
 AS RANGE LEFT FOR VALUES
(
'20070131 23:59:59.997',
'20070228 23:59:59.997',
'20070331 23:59:59.997',
'20070430 23:59:59.997',
'20070531 23:59:59.997',
'20070630 23:59:59.997',
'20070731 23:59:59.997',
'20070831 23:59:59.997',
'20070930 23:59:59.997',
'20071031 23:59:59.997',
'20071130 23:59:59.997',
'20071231 23:59:59.997'
) ;
 

ALTER DATABASE newcsdnblog ADD FILEGROUP [ViewCount200701];
ALTER DATABASE newcsdnblog ADD FILEGROUP [ViewCount200702];
ALTER DATABASE newcsdnblog ADD FILEGROUP [ViewCount200703];
ALTER DATABASE newcsdnblog ADD FILEGROUP [ViewCount200704];
ALTER DATABASE newcsdnblog ADD FILEGROUP [ViewCount200705];
ALTER DATABASE newcsdnblog ADD FILEGROUP [ViewCount200706];
ALTER DATABASE newcsdnblog ADD FILEGROUP [ViewCount200707];
ALTER DATABASE newcsdnblog ADD FILEGROUP [ViewCount200708];
ALTER DATABASE newcsdnblog ADD FILEGROUP [ViewCount200709];
ALTER DATABASE newcsdnblog ADD FILEGROUP [ViewCount200710];
ALTER DATABASE newcsdnblog ADD FILEGROUP [ViewCount200711];
ALTER DATABASE newcsdnblog ADD FILEGROUP [ViewCount200712];

ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N'ViewCount200701',FILENAME = N'd:\sqlserverdata\SmallTableViewCount200701.ndf',SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ViewCount200701];
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N'ViewCount200702',FILENAME = N'd:\sqlserverdata\SmallTableViewCount200702.ndf',SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ViewCount200702];
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N'ViewCount200703',FILENAME = N'd:\sqlserverdata\SmallTableViewCount200703.ndf',SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ViewCount200703];
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N'ViewCount200704',FILENAME = N'd:\sqlserverdata\SmallTableViewCount200704.ndf',SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ViewCount200704];
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N'ViewCount200705',FILENAME = N'd:\sqlserverdata\SmallTableViewCount200705.ndf',SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ViewCount200705];
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N'ViewCount200706',FILENAME = N'd:\sqlserverdata\SmallTableViewCount200706.ndf',SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ViewCount200706];
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N'ViewCount200707',FILENAME = N'd:\sqlserverdata\SmallTableViewCount200707.ndf',SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ViewCount200707];
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N'ViewCount200708',FILENAME = N'd:\sqlserverdata\SmallTableViewCount200708.ndf',SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ViewCount200708];
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N'ViewCount200709',FILENAME = N'd:\sqlserverdata\SmallTableViewCount200709.ndf',SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ViewCount200709];
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N'ViewCount200710',FILENAME = N'd:\sqlserverdata\SmallTableViewCount200710.ndf',SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ViewCount200710];
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N'ViewCount200711',FILENAME = N'd:\sqlserverdata\SmallTableViewCount200711.ndf',SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ViewCount200711];
ALTER DATABASE newcsdnblog
ADD FILE
(NAME = N'ViewCount200712',FILENAME = N'd:\sqlserverdata\SmallTableViewCount200712.ndf',SIZE = 5MB,MAXSIZE = 100MB,FILEGROWTH = 5MB)
TO FILEGROUP [ViewCount200712];
;
CREATE PARTITION SCHEME OneYearDateRangePScheme
AS
PARTITION OneYearDateRangePFN
ALL TO ([PRIMARY])
;

CREATE TABLE [dbo].[Blog_ViewCount2] 
(
[EntryID] [int] NOT NULL,
[BlogID] [int] NOT NULL,
[ViewDate] [datetime] NOT NULL
)
ON OneYearDateRangePScheme (ViewDate)
GO
;
select $partition.partition_fn_town_year_new(partition_field), COUNT(*) from student_score1 a
group by $partition.partition_fn_town_year_new(partition_field)
阅读(1195) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~