Skip to main content

How do you drop a column from a table?

Dropping a column from a table is done with the ALTER TABLE command and the DROP COLUMN clause.

Syntax:

sql
ALTER TABLE Table_Name DROP COLUMN Column_Name;

Example:

sql
ALTER TABLE Employees DROP COLUMN Salary;

Explanation:

  • ALTER TABLE Employees, picks the table we want to change.
  • DROP COLUMN Salary, drops the Salary column along with all its data.

Notes

  • Once a column is dropped, its data is irreversibly lost.
  • Some DBMSs let you drop several columns in a single query:
sql
ALTER TABLE Employees DROP COLUMN Salary, DROP COLUMN HireDate;

The takeaway: this command should be used carefully, since recovering the data will be impossible without a backup.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.