/    /  MySQL – Delete Column

MySQL – Delete Column

MySQL - Delete Column

In some cases, we may want to remove a single column or multiple columns from a table. The ALTER TABLE DROP COLUMN statement allows you to delete a column from the table.

Syntax:

ALTER TABLE table_name  DROP COLUMN column_name;  
  • As a first step, we must specify the table name from which the column should be removed.
  • In the next step, after specifying the DROP COLUMN clause, we must specify the column name that should be removed from the table. There is a COLUMN keyword that is optional in the DROP COLUMN statement.

Example

ALTER TABLE employees  DROP COLUMN city;

MySQL - Delete Column

We can remove multiple columns from the table by executing the following command:

Syntax:

ALTER TABLE table_name  
DROP COLUMN column_1,  
DROP COLUMN column_2,  
......;  

Example

ALTER TABLE employees  
DROP COLUMN country,  
DROP COLUMN age;

MySQL - Delete Column