Add column after a column in mysql

Sometimes you will want to add a column after another column in mysql. To do this requires the alter table syntax, so be sure that the user you intend to use to alter table has alter privileges.

Here is an example of how one would use the alter command to do this

alter table test add column newcolumn varchar(255) after existingcolumn;

This command will alter some table named “test” and add a column called “newcolumn” AFTER a column “existingcolumn”. The “newcolumn” will also have a datatype of varchar.

Be the first to comment

Leave a Reply