Reputation: 533
In clickhouse, the table is partitioned by day. Now I want to drop multi-partition in one alter
query for convenience.
I've done this by shell using while loop:
while [[ $startDate < $endDate ]]
do
clickhouse-client --query="alter table db.table drop partition toYYYYMMDD(toDate($startDate))"
startDate=`date -d "+1 day $startDate" +%Y-%m-%d`
done
And I just want to find some way that can do this easily. Is there some way? Thanks~
Upvotes: 7
Views: 12740
Reputation: 546
You can use this
ALTER TABLE my_table ON CLUSTER 'my-cluster'
DROP PARTITION '2020-01-01',
DROP PARTITION '2020-01-02',
DROP PARTITION '2020-01-03'
Unfortunately, seems like there is nothing more convenient yet.
Upvotes: 3
Reputation: 3276
You can instead use ALTER TABLE <table> DELETE WHERE <partition-filters>
to drop multiple partitions in one go.
Upvotes: 0