SQL SERVER Performance Tuning four: Creating a partitioned Table

Source: Internet
Author: User
Tags filegroup

There should be different filegroups in the database before the partition table is created;

Assuming the database name is Df17datapro, create the user table UserID, put the first 500,000 data in the primary filegroup, place the 50~100 in the FG1 filegroup, and put more than 100 in the FG2 filegroup

1. Add File group Fg1,fg2

ALTER  DATABASE Df17datapro ADD FILEGROUP FG1
ALTER  DATABASE df17dataproadd FILEGROUP fg2

2. Adding files to a filegroup

ALTER TABLEDf17dataproADD FILE(NAME=Df17datapro1,filename='D:\DF17DATAPRO.NDF') toFILEGROUP fg1ALTER TABLEDf17dataproADD FILE(NAME=Df17datapro2,filename='E:\DF17DATAPRO.NDF') toFILEGROUP FG2

3. Create a partition function

CREATE Partitionfunction myrangefunction (int)
As RANGE right for VALUES (500000,1000000)
GO

4. Create partition scheme based on partition function

CREATE PARTITION SCHEME Myrangeschema  as PARTITION  Myrangefunctionto (PRIMARY, FG1,FG2)

5. Specify ID column to create user table as partition scheme

CREATE TABLE USER  int notNULL   varchar (null  on Myrangeschema (UserID)

SQL SERVER Performance Tuning four: Creating a partitioned Table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.