partition
DETACH PARTITION
Remove a child from the partition hierarchy without deleting its stored rows. Review locks and dependencies; concurrent detachment has additional restrictions.
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');INSERT INTO events VALUES ('2025-01-10');ALTER TABLE events DETACH PARTITION jan;SELECT (SELECT count(*) FROM events),(SELECT count(*) FROM jan);