Removes an existing column from a table, permanently deleting its data and metadata.
Free disk space, simplify the schema, or remove sensitive data no longer required. Dropping eliminates the column and its contents forever, so create a backup first.
Use ALTER TABLE followed by the table name, then DROP COLUMN and the column name. Add IF EXISTS to avoid errors when the column might already be gone.
ALTER TABLE instructs PostgreSQL to change a table; DROP COLUMN removes the specified column; CASCADE drops dependent objects like indexes or views, while RESTRICT (default) blocks the action if dependencies exist.
1️⃣ Validate no application code or queries reference the column. 2️⃣ Check dependencies with pg_depend or psql \d+. 3️⃣ Issue ALTER TABLE … DROP COLUMN inside a transaction so you can ROLLBACK if needed.
BEGIN; ALTER TABLE "Orders" DROP COLUMN shipping_method; COMMIT; The transaction ensures either full success or no change.
Yes, PostgreSQL takes an ACCESS EXCLUSIVE lock for a very short time. Reads and writes wait during the catalog update, but the lock is usually milliseconds unless the table is huge.
Yes. Separate each DROP COLUMN clause with a comma: ALTER TABLE "Products" DROP COLUMN supplier_id, DROP COLUMN discontinued_at;
Back up first, drop in low-traffic windows, monitor replication lag, test in staging, and always use IF EXISTS in automated scripts.
Using CASCADE blindly can delete views or foreign keys you still need. Forgetting to update ORM models causes runtime errors after deployment.
No. You must restore from backup or recreate the column and reload data.
After dropping, sequential scans become slightly faster because fewer columns are read from disk.
Only after removing or altering the constraint; otherwise PostgreSQL blocks the operation.