MySQL: How to add column to existing table


mysql how to add columnMany ways to add column to existing table in MySQL. If you r using GUI tools, add column to table in MySQL is easy. If you are using CLI, then here’s the command to add column in MySQL table.

To add column in existing table, you may refer to the 2 examples below:-

Advertisements

Example I: Add new varchar column to the end of the table

Example II: Add new integer column after an existing column in table

It’s simple to add column to existing table right? 🙂

Related posts:






Share this with your friends:-

2 Responses to “MySQL: How to add column to existing table”

  1. leandro says:

    ok. I already know how to do it:
    alter table table_name add column user_id int, add foreign key(user_id) references user(id);

  2. leandro says:

    and if the new key is a constraint, like a foreign key?

Leave a Reply