Description

You can execute the ALTER PARTITION TABLE statement to modify a partition table.

Synopsis

Currently, you can modify a partition table in Hologres by executing one of the following SQL statements:

ALTER TABLE [IF EXISTS] table_name RENAME to new_table_name;
ALTER TABLE [IF EXISTS] table_name ATTACH PARTITION new_partition_name FOR VALUES in (<string_literal>);
ALTER TABLE [IF EXISTS] table_name DETACH PARTITION paritition_name;

Parameters

  1. RENAME: This clause renames the specified partition table.
  2. ATTACH PARTITION new_partition_name FOR VALUES in (<string_literal>): This clause uses the same expression partition_bound_spec as CREATE TABLE. It attaches an existing table (which may itself be partition) as a partition of the target table. Make sure that the following conditions are met before you attach the existing table:
    • The partition_bound_spec expression must correspond to the partitioning strategy and partition key of the target table.
    • The table to be attached must have all the same columns as the target table.
    • The column types must also match.
    • The table to be attached must have all the NOT NULL constraints of the target table. If you attach a list partition that does not accept NULL values, also add the NOT NULL constraint to the partition key column, unless it is an expression.
  3. DETACH PARTITION partition_name: This clause detaches a specified partition from the target table. The detached partition still exists as a standalone table, but no longer has any ties to the table from which it was detached.

Examples

ALTER TABLE holo_test RENAME to my_holo_test;// Rename the holo_test partition table.

ALTER TABLE holo_table ATTACH PARTITION my_table FOR VALUES in ('2015');// Attach the holo_table table as a partition of the my_table table.

ALTER TABLE all_test DETACH PARTITION holo_test; // Detach the all_test partition from the holo_test table.