悉野小楼

导航

sqlserver表分区

 

参考:http://www.cnblogs.com/knowledgesea/p/3696912.html

及百度搜索sqlserver表分区

 

create partition 
function sgy_partitionfun (int) as range left for values(N'10000', N'20000')

//drop partition function sgy_partitionfun



BEGIN TRANSACTION


--创建分区方案
CREATE PARTITION SCHEME [bgPartitionSchema] AS PARTITION sgy_partitionfun TO ([PRIMARY], filegroup1, filegroup2)

--创建分区索引
CREATE CLUSTERED INDEX [ClusteredIndex_on_bgPartitionSchema_635342971076448165] ON gms_item
(
    gameserverid
)WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [bgPartitionSchema](gameserverid)

--删除分区索引
DROP INDEX [ClusteredIndex_on_bgPartitionSchema_635342971076448165] ON gms_item WITH ( ONLINE = OFF )

COMMIT TRANSACTION

select * from gms_item where $partition.sgy_partitionfun(gameserverid)=1

  

posted on 2015-08-21 17:35  悉野  阅读(211)  评论(0编辑  收藏  举报