我们之前大致的语法是这样的
-- =========================
-- 演示:陈希章
-- 如何创建分区函数
-- 如何创建分区架构
-- 如何创建分区表
--=========================
alter database adventureWorks add filegroup [fg1]
go
alter database adventureWorks add filegroup [fg2]
go
alter database adventureWorks add filegroup [fg3]
go
alter database adventureWorks
add file
(name='fg1',
filename='c:\fg1.ndf',
size=5mb)
to filegroup [fg1]
go
alter database adventureWorks
add file
(name='fg2',
filename='d:\fg2.ndf',
size=5mb)
to filegroup [fg2]
go
alter database adventureWorks
add file
(name='fg3',
filename='e:\fg3.ndf',
size=5mb)
to filegroup [fg3]
go
use adventureWorks
go
Create partition function emailPF(nvarchar(50)) as range right for values ('G','N')--创建分区函数
go
Create partition scheme emailPS as partition emailPF to (fg1,fg2,fg3)--创建分区方案
go
Create table customermail (custid int, email nvarchar(50)) on emailPS(email)--创建分区表
Go
为了简化操作,SQL Server 2008中为表分区提供了相关的操作
最后生成的脚本是这样的
USE [demo]
GO
BEGIN TRANSACTION
CREATE PARTITION FUNCTION [ordersfunction](date) AS RANGE LEFT FOR VALUES (N'2008-01-01', N'2008-02-01', N'2008-03-01')
CREATE PARTITION SCHEME [ordersscheme] AS PARTITION [ordersfunction] TO ([PRIMARY], [PRIMARY], [PRIMARY], [PRIMARY])
CREATE CLUSTERED INDEX [ClusteredIndex_on_ordersscheme_633765890752500000] ON [dbo].[Orders]
(
[OrderDate]
)WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [ordersscheme]([OrderDate])
DROP INDEX [ClusteredIndex_on_ordersscheme_633765890752500000] ON [dbo].[Orders] WITH ( ONLINE = OFF )
COMMIT TRANSACTION
除了提供了创建分区的向导之外,还有一个管理分区的向导,主要是可以做SWITCH,MERGE,SPLIT这些操作。也可以查看数据除了这些图形化工具的支持之外,SQL Server 2008的分区表还有不少增强,诸如性能等等方面
http://technet.microsoft.com/zh-cn/library/ms345599.aspx