How to Add or Drop a column from an existing MySQL table?

January 12, 2008 – 9:05 am

Add a column to MySQL table

To add a new column col_name to the existing table table_name of VARCHAR datatype or any datatype then use ALTER TABLE as follows use the following SQL statement:

ALTER TABLE table_name ADD col_name VARCHAR(size);

This statement by default adds a new column at the end of the table.

ALTER TABLE table_name ADD col_name VARCHAR(size) FIRST;

This statement adds the new column at the begining or starting of the table.

ALTER TABLE table_name ADD col_name VARCHAR(size) AFTER col_name3;

This statement adds the new column after col_name3.

Drop a column from an existing MySQL Table

To drop a column from the existing table use DROP as below

ALTER TABLE table_name DROP col_name;

Share/Save/Bookmark

Post a Comment