How To Delete Column From Table In Sql in SQL
How to Delete (Drop) a Column from a Table in SQL
You use the ALTER TABLE statement with the DROP COLUMN clause to remove a column from an existing table.
Syntax:
ALTER TABLE table_nameDROP COLUMN column_name;Example:
Suppose you have a table employees with a column middle_name you want to delete:
ALTER TABLE employeesDROP COLUMN middle_name;Notes:
Some databases may have slightly different syntax or restrictions (e.g., older versions of MySQL didn't support dropping columns).
Dropping a column removes all data in that column permanently.
You cannot drop a column if it’s used in constraints like primary key or foreign key without dropping those constraints first.
Database-specific notes:
| Database | Notes |
|---|---|
| MySQL | Supports DROP COLUMN |
| SQL Server | Supports DROP COLUMN |
| PostgreSQL | Supports DROP COLUMN |
| Oracle | Supports DROP COLUMN |
If you want, I can help you with the exact command for your database!