Exchanging a Partition in Greenplum

Exchanging a partition involves swapping in another table in place of an existing partition. You can exchange a partition using the ALTER TABLE command. You can only exchange partitions at the lowest level of your partition hierarchy (only partitions that contain data can be exchanged).

This can be useful for data loading. For example, you could load a staging table and then swap the loaded table into your partition design. You can also use exchange to change the storage type of older partitions to append-only tables. For example:

CREATE TABLE jan08 (LIKE sales) WITH (appendonly=true);

INSERT INTO jan08 SELECT * FROM sales_1_prt_1 ;

ALTER TABLE sales EXCHANGE PARTITION FOR ('2008-01-01') WITH TABLE jan08;
Comments