Delete Multiple Partitions in Hive: Guide
To delete data from multiple partitions, you can use the ALTER TABLE statement to delete partitions. Here are the steps to delete data from multiple partitions:
- First, use the DESCRIBE EXTENDED command to view the partition information of the table and locate the name of the partition to be deleted.
- Next, use the ALTER TABLE statement to remove data from multiple partitions. For example, to delete partitions p1 and p2, you can use the following command:
ALTER TABLE table_name DROP IF EXISTS PARTITION (partition_col='p1'), PARTITION (partition_col='p2');
- To confirm if the deletion operation was successful, you can use the DESCRIBE EXTENDED command to check the partition information of the table again and confirm if the partition to be deleted has been successfully removed.