ALTER TABLE … DROP COLUMN permanently removes one or more columns from an existing table.
ALTER TABLE … DROP COLUMN deletes a column and its data forever. Use it to clean schemas, reduce storage, and simplify queries.
Remove obsolete, redundant, or migrated data. Cleaning unused columns keeps tables small, improves cache efficiency, and lowers maintenance overhead.
Use ALTER TABLE table_name DROP [IF EXISTS] column_name [CASCADE | RESTRICT]
. Add ,
-separated clauses to drop multiple columns in one statement.
ALTER TABLE employees DROP COLUMN middle_name;
The column and all its data disappear immediately. No table rewrite occurs if the column is not part of any index or constraint.
ALTER TABLE orders
DROP COLUMN IF EXISTS promo_code,
DROP COLUMN IF EXISTS ship_notes;
Multiple DROP COLUMN clauses run in one transaction, avoiding extra locks and reducing replication lag.
CASCADE automatically removes dependent objects—views, triggers, foreign keys—that reference the column. RESTRICT (default) blocks the command if dependents exist.
Yes. PostgreSQL marks the space as free immediately. Autovacuum later returns it to the file system after freezing dead tuples.
Backup the table or schema, confirm no application code uses the column, drop during low-traffic windows, and test on staging first.
The statement is WAL-logged. Standby servers apply it automatically, keeping schema in sync across clusters.
It acquires an ACCESS EXCLUSIVE lock but usually completes quickly. For large tables, schedule during maintenance windows.
Not directly. You must restore from backup or recreate the column and repopulate data manually.
Yes. The WAL record is streamed, so standbys execute the same ALTER TABLE statement automatically.