ALTER TABLE - DROP column clause

The DROP clause of the MySQL statement, ALTER TABLE removes a given column from a MySQL table and delete the column's data. These clauses of the MySQL statement, add columns to a MySQL table.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

ALTER [IGNORE] TABLE table
DROP [COLUMN] column

Explanation

The DROP clause of the MySQL statement, ALTER TABLE removes a given column from a MySQL table and delete the column's data. A table must have at least one column, so this statement will fail if used on the only column in a table. You can, however, delete the table using the DROP TABLE statement. If a dropped column is part of an index, the column will be removed automatically from the index definition. If all of the columns of an index are dropped, the index will automatically be dropped.

Examples

Here is an example of this MySQL statement including this clause:

ALTER TABLE clients
DROP COLUMN miscellaneous,
DROP COLUMN comments;

This MySQL statement drops two columns and deletes the data they contain without warning. Notice that multiple columns may be dropped by separating each clause by commas. It's not possible to combine clauses, though. That is to say, ...DROP COLUMN (miscellaneous, comments) is not permitted. Once a column has been deleted, you won't be able to recover its data from MySQL. Instead, you'll have to restore the table from a backup of your data if you made one.