Reputation: 57
I have in Msql database several tables with lots of rows and columns in them. I need to create a new column in one of these tables.
How do I create an SQL query for inserting a new column in a specific table via PhpMyAdmin?
Upvotes: 1
Views: 4854
Reputation: 1461
Syntax:
ALTER TABLE tableName ADD columnName columnType;
Example:
ALTER TABLE people ADD hometown VARCHAR(50);
You can use this query in phpMyAdmin by going to the SQL tab after selecting your database.
Also, you may use the graphical user interface to add a column by following the steps:
Upvotes: 2
Reputation: 12535
ALTER TABLE tbl_name ADD [COLUMN] col_name column_definition [FIRST | AFTER col_name ]
Link: http://dev.mysql.com/doc/refman/5.1/en/alter-table.html
Upvotes: 0
Reputation: 2415
Simple google revealed this and this
ALTER TABLE contacts ADD email VARCHAR(60);
Upvotes: 0
Reputation: 56357
alter table table_name add column new_column int after id
In my example I have added a new column that has data type int after id column. Very easy.
Upvotes: 5