Detaching and Attaching Partitions
Use ATTACH PARTITION and DETACH PARTITION to roll partitions in and out without blocking reads.
Why Detach?
You can swap an old partition out of the live table without dropping data. Common uses:
- Archive to a separate database
- Move to cheaper storage
- Backup-then-drop pattern
DETACH PARTITION
Removes the partition from the parent but keeps the data:
ALTER TABLE events DETACH PARTITION events_2022;
-- events_2022 is now a standalone table.
-- Queries on events no longer see those rows.All lessons in this course
- Why Partition: Pruning, Maintenance
- Range, List and Hash Partitioning
- Detaching and Attaching Partitions
- Querying Across Partitions Efficiently