partition
Partition maintenance
Plan retention by creating future partitions and archiving detached partitions. Inspect dependencies and verify backups before any deletion. Partitioning does not replace indexes or backup.
Formal Syntax & Structure
sql syntaxsql
ALTER TABLE parent DETACH PARTITION child;Working Example
Example Snippetsql
-- Run independently in a fresh disposable PostgreSQL database/schema.CREATE TABLE events(d date) PARTITION BY RANGE(d);CREATE TABLE jan PARTITION OF events FOR VALUES FROM ('2025-01-01') TO ('2025-02-01');CREATE TABLE feb PARTITION OF events FOR VALUES FROM ('2025-02-01') TO ('2025-03-01');ALTER TABLE events DETACH PARTITION jan;