SQL Server creates table partitions

Source: Internet
Author: User

Prepare the test table first

CREATE TABLE [dbo]. [Employee] (    INTIDENTITY(1,1PRIMARYKEY ,     NVARCHAR (NULL);

Insert some data

INSERT DEFAULT VALUES ; GO 10000 UPDATE Set = '  '+CONVERT(VARCHAR

Creating filegroups

Create a file (for performance, you can set the file path to be distributed on different disk partitions)

Create partition Prep

Select a partition column

Create a partition function

Creating a partitioned Framework

Define boundary values, partitioning, because there are 5 boundary values, so 6 partitions are required

The resulting script file (in other words the above step is equivalent to the following statement)

 Use [Testingdb]GOBEGIN TRANSACTIONCREATEPARTITIONFUNCTION [empfunction](int) asRANGE Right  for VALUES(N' -'N'4000'N'6000'N'8000'N'10000')CREATEPARTITION SCHEME[Funscheme]  asPARTITION[empfunction]  to([FileGroup1],[FileGroup2],[FileGroup3],[FileGroup4],[FILEGROUP5],[PRIMARY])ALTER TABLE [dbo].[Employee] DROP CONSTRAINT [pk__employee__7ad0f1b633d4b598]ALTER TABLE [dbo].[Employee] ADD PRIMARY KEY CLUSTERED (    [Employeeno] ASC) with(Pad_index= OFF, Statistics_norecompute= OFF, sort_in_tempdb= OFF, Ignore_dup_key= OFF, ONLINE= OFF, Allow_row_locks=  on, Allow_page_locks=  on) on [Funscheme]([Employeeno])COMMIT TRANSACTION

Execute the above SQL statement

Where the statement on [Funscheme] ([Employeeno]) is key, indicating that the table employee relies on the partition framework Funscheme to partition, the partition is listed as Employeeno

The partition framework relies on partition functions, that is, partitioned tables rely on partition framework, and partition framework relies on partition function

View Table Partitioning Results

SQL Server creates table partitions

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.