You can change the way a table or index is partitioned by adding or subtracting the number of partitions specified, in increments of 1, in the partition function of the partitioned table or index.
When you add a partition, you do so by "splitting" an existing partition into two partitions and redefining the boundaries of the new partitions. When you drop a partition, you do so by "merging" the boundaries of two partitions into one. This last action repopulates one partition and leaves the other partition unassigned.
Important: |
|---|
|
When adding a partition, a filegroup must exist and be marked with the NEXT USED property to hold the new partition. For information about how to specify a NEXT USED filegroup in a partition scheme, see Modifying a Partition Scheme later in this topic.
|
ALTER PARTITION FUNCTION can only be used for splitting one partition into two, or for merging two partitions into one. To change the way a table or index is partitioned (from 10 partitions to 5, for example), you can use any one of the following options. Depending on the configuration of your system, these options can vary in the resource consumption they use.
-
Create a new partitioned table with the partition function you want, and then insert the data from the old table into the new table by using an INSERT INTO...SELECT FROM statement.
-
Create a partitioned clustered index on a heap.
Note: |
|---|
|
Partitioned indexes that are dropped will cause partitioned heaps.
|
-
Drop and rebuild an existing partitioned index using the Transact-SQL CREATE INDEX command with the DROP EXISTING = ON clause.
-
Perform a sequence of ALTER PARTITION FUNCTION statements.
SQL Server does not provide replication support for modifying a partition function. If you want to make changes to a partition function in the publication database, you must do this manually in the subscription database.
To modify a partition function