SQL DROP COLUMN is a sub-command of ALTER TABLE that permanently deletes a column definition and every value stored in that column. Because the operation rewrites the underlying table metadata, it is irreversible without a backup. All dependent objects such as indexes, constraints, and views that reference the column must either be removed first or dropped automatically with the CASCADE option (where supported). Some engines rewrite the entire table to complete the operation, which can lock the table or require additional disk space. Always confirm that the column is no longer needed and that backups exist before executing DROP COLUMN.
- table_name
(identifier) - Name of the target table.- IF EXISTS
(keyword, optional) - Drop only if the column is present; prevents an error when absent.- column_name
(identifier) - Name of the column to remove.- CASCADE
(keyword, optional) - Automatically drop objects that depend on the column.- RESTRICT
(keyword, optional) - Refuse to drop if any dependent objects exist (default in many dialects).ALTER TABLE, ADD COLUMN, RENAME COLUMN, DROP TABLE, DROP CONSTRAINT
SQL-92 (ALTER TABLE)
Back up the table, verify no application code relies on the column, and use IF EXISTS to avoid runtime errors. In PostgreSQL, test in a staging environment first.
Yes in most dialects. List each column separated by commas: `ALTER TABLE users DROP COLUMN age, DROP COLUMN nickname;`.
Depends on the engine. Some reclaim space immediately; others wait until VACUUM or OPTIMIZE tasks run.
Query the system catalog (e.g., `pg_catalog.pg_depend` in PostgreSQL or `information_schema.key_column_usage` in MySQL) to locate constraints, indexes, or views that reference the column.