• SQL Server 2008 建立分区表 脚本


    /*第一步:创建分区函数*/
    Create partition function Part_func_Bag(varchar(20)) as range right
    /*正式区间for values(N'01100923909760', N'01100936207030', N'6311001806524',N'92451400060101');*/
    for values(N'91701311710807', N'07201280707101', N'8011011089884',N'80241001430714');
    go
    select * from Bag where
    BagCode in(N'91701311710807', N'07201280707101', N'8011011089884',N'80241001430714')

    /*第二步:创建文件组和文件*/
    alter database ZXAutoCode add filegroup [Bag_1];
    alter database ZXAutoCode add filegroup [Bag_2];
    alter database ZXAutoCode add filegroup [Bag_3];
    alter database ZXAutoCode add filegroup [Bag_4];
    go

    alter database ZXAutoCode add file (name = Bag1_data,filename = 'E:MSSQLTESTDATABag1_data.ndf',size = 3MB) to filegroup [Bag_1];
    alter database ZXAutoCode add file (name = Bag2_data,filename = 'E:MSSQLTESTDATABag2_data.ndf',size = 3MB) to filegroup [Bag_2];
    alter database ZXAutoCode add file (name = Bag3_data,filename = 'E:MSSQLTESTDATABag3_data.ndf',size = 3MB) to filegroup [Bag_3];
    alter database ZXAutoCode add file (name = Bag4_data,filename = 'E:MSSQLTESTDATABag4_data.ndf',size = 3MB) to filegroup [Bag_4];
    go

    /*第三步:创建分区方案并关联到分区函数*/
    Create partition scheme Part_func_Bag_scheme as partition Part_func_Bag to ([Bag_1],[Bag_2],[Bag_3],[Bag_4],[Primary]);
    go


    /*第四步 重建索引(删除聚集索引以及需要分区字段的索引后重建该类索引,表被按分区值将分配到各文件组。数据在这一步开始转移。)*/
    EXEC sp_helpindex N'Bag' --查看orders中使用的索引
    drop index idx_cl_od on Bag;
    go


    create clustered index idx_cl_od on Bag(bagcode)
    on Part_func_Bag_scheme(bagcode);
    go

  • 相关阅读:
    Exp8-Web综合
    Exp7-网络欺诈防范
    Exp6-MSF应用基础
    加密API学习
    Exp5 信息搜集与漏洞扫描
    Exp4-恶意代码分析
    Exp3-免杀原理
    Exp2-后门原理与实践
    leetcode 22括号生成 暴力法
    413 等差数列划分
  • 原文地址:https://www.cnblogs.com/zhuawang/p/3560820.html
Copyright © 2020-2023  润新知