Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting a Column to preexisting table in phpmyadmin

Tags:

I want to add a column to preexisting table. Can I add it in between two existing columns? I am working on phpmyadmin.

like image 814
StrawhatLuffy Avatar asked Aug 05 '13 17:08

StrawhatLuffy


People also ask

How do I add a column to an existing table in MySQL?

The syntax to add a column in a table in MySQL (using the ALTER TABLE statement) is: ALTER TABLE table_name ADD new_column_name column_definition [ FIRST | AFTER column_name ]; table_name.

Can we add column to the existing table with data?

If you know SQL then you probably know that you can add columns to an existing table in SQL Server using the ALTER command. It not only allows you to add a column but to drop columns as well. You can also add or drop constraints using the ALTER command.

How do I add a column and data to an existing table?

Step 1: Create a new column with alter command. ALTER TABLE table_name ADD column_name datatype; Step 2: Insert data in a new column.


2 Answers

Use the add new column after dropdown.

  1. Select the database from the menu on the left.

  2. Select the table by clicking on it's title column hyperlink.

  3. Check the add new column after radio button and select the column you want to insert after in the drop down.

  4. Click Add.

This video goes through the process http://www.youtube.com/watch?v=jZ72GCGWPQg

like image 162
danmc Avatar answered Sep 18 '22 08:09

danmc


You want something like:

ALTER TABLE contacts ADD email VARCHAR(60); 
like image 29
Vaughan Hilts Avatar answered Sep 18 '22 08:09

Vaughan Hilts