Dropping multiple columns in MySQL

Is it possible to drop numerous columns from a table at once in MySQL?

The answer is Yes.

Here is the syntax and example:

ALTER TABLE `tableName`
DROP COLUMN Col1,
DROP COLUMN Col2,
DROP COLUMN Col3,
….;

ALTER TABLE `tbOrdersDetail`
DROP COLUMN OrderID,
DROP COLUMN ProductID;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s