Adding a New Partition in Greenplum

Adding a New Partition

You can add a new partition to an existing partition design using the ALTER TABLE command. If the original partition design included subpartitions defined by a subpartition template, then the newly added partition will also be subpartitioned according to that template. For example:

ALTER TABLE sales ADD PARTITION
START (date '2009-02-01') INCLUSIVE
END (date '2009-03-01') EXCLUSIVE;

If a subpartition template was not used when you created the table, you would then define subpartitions when adding a new partition:

ALTER TABLE sales ADD PARTITION
START (date '2009-02-01') INCLUSIVE
END (date '2009-03-01') EXCLUSIVE
( SUBPARTITION usa VALUES ('usa'),
SUBPARTITION asia VALUES ('asia'),
SUBPARTITION europe VALUES ('europe') );

If you want to add a new subpartition to an existing partition, you can specify a particular partition to alter. For example:

ALTER TABLE sales ALTER PARTITION FOR (RANK(12))
ADD PARTITION africa VALUES ('africa');

Note: You cannot add a new partition to a partition design that has a default partition. You must split the default partition in order to add a new partition.
Comments