Adding multiple columns in a table – MySQL

When you engage with several RDBMSs, even a small amount of change in syntax can cause confusion. This is the first in a series of postings about how to add multiple columns to different RDBMSs. However, this article will focus on MySQL syntax.

Syntax:

ALTER TABLE tableName
ADD COLUMN `column1` dataType,
ADD COLUMN `column2` dataType,
ADD COLUMN `column3` dataType;

Example:
ALTER TABLE Customers
ADD COLUMN `CxID` SMALLINT(6) NOT NULL,
ADD COLUMN `LastName` VARCHAR(20),
ADD COLUMN `status` INT(10) UNSIGNED NOT NULL;

Hope you find this article helpful.

Please subscribe for more interesting updates.

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