This statement is used to delete one or more partitions based on specified conditions.
1 2 3 | ALTER TABLE [db_name.]table_name DROP [IF EXISTS] PARTITIONS partition_filtercondition; |
Parameter |
Description |
---|---|
db_name |
Database name that contains letters, digits, and underscores (_). It cannot contain only digits or start with an underscore (_). |
table_name |
Table name of a database that contains letters, digits, and underscores (_). It cannot contain only digits or start with an underscore (_). The matching rule is ^(?!_)(?![0-9]+$)[A-Za-z0-9_$]*$. If special characters are required, use single quotation marks ('') to enclose them. This statement is used for OBS table operations. |
partition_filtercondition |
Condition used to search partitions to be deleted. The format is as follows:
|
You can run the following statements to delete partitions of the student table using different conditions:
1 2 3 4 5 6 7 8 | alter table student drop partitions(start_date < '201911'); alter table student drop partitions(start_date >= '202007'); alter table student drop partitions(start_date BETWEEN '202001' AND '202007'); alter table student drop partitions(start_date < '201912' OR start_date >= '202006'); alter table student drop partitions(start_date > '201912' AND start_date <= '202004'); alter table student drop partitions(start_date != '202007'); alter table student drop partitions(start_date <> '202007'); alter table student drop partitions(start_date <> '202007'), partitions(start_date < '201912'); |