Home » Database » MySQL: How to add a new column to an existing table

MySQL: How to add a new column to an existing table



Do you want to add a new column to an existing table in MySQL. You cannot only add a new column, you can even decide the positioning of the column in your MySQL database table. For instance, if you want to add a new column in the last, you merely use this command:

alter table mytable add column new_column_name varchar(255)

If you want the new column to be the first column you use this command:

alter table mytable add new column new_column_name varchar(255) first

And if you want this new column to appear after an already existing column you do the following:

alter table mytable add new column new_column_name after older_column_name

[tags]mysql tips[/tags]