ALTER TABLE PARTITION
This statement is used to modify a table with a partition.
This operation is synchronous, and the return of the command indicates the completion of the execution.
grammar:
ALTER TABLE [database.]table alter_clause;
The alter_clause of partition supports the following modification methods
grammar:
ADD PARTITION [IF NOT EXISTS] partition_name partition_desc ["key"="value"] [DISTRIBUTED BY HASH (k1[,k2 ...]) [BUCKETS num]]
Notice:
10 will be used for bucket number instead of the number specified when the table is created. If the number of buckets modified, the bucketing method needs to be specified simultaneously.grammar:
DROP PARTITION [IF EXISTS] partition_name [FORCE]
Notice:
grammar:
MODIFY PARTITION p1|(p1[, p2, ...]) SET ("key" = "value", ...)
illustrate:
ALTER TABLE example_db.my_table ADD PARTITION p1 VALUES LESS THAN ("2014-01-01");
ALTER TABLE example_db.my_table ADD PARTITION p1 VALUES LESS THAN ("2015-01-01") DISTRIBUTED BY HASH(k1) BUCKETS 20;
ALTER TABLE example_db.my_table ADD PARTITION p1 VALUES LESS THAN ("2015-01-01") ("replication_num"="1");
ALTER TABLE example_db.my_table MODIFY PARTITION p1 SET("replication_num"="1");
ALTER TABLE example_db.my_table MODIFY PARTITION (p1, p2, p4) SET("replication_num"="1");
ALTER TABLE example_db.my_table MODIFY PARTITION (*) SET("storage_medium"="HDD");
ALTER TABLE example_db.my_table DROP PARTITION p1;
ALTER TABLE example_db.my_table DROP PARTITION p1, DROP PARTITION p2, DROP PARTITION p3;
ALTER TABLE example_db.my_table ADD PARTITION p1 VALUES [("2014-01-01"), ("2014-02-01"));
ALTER TABLE example_db.my_table ADD PARTITIONS FROM (1) TO (100) INTERVAL 10; ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 YEAR; ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 MONTH; ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 WEEK; ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 DAY;
ALTER, TABLE, PARTITION, ALTER TABLE