Reputation: 44086
Alter table users
Add
{
};
and if so how would i add all three of these columns
`user_id` varchar(16) DEFAULT NULL,
`user_location` tinytext,
`author_id` varchar(16) DEFAULT NULL,
Upvotes: 1
Views: 291
Reputation: 54445
To be honest, you're not really doing yourself any favours by asking such as question, as you won't learn anything from an actual answer. (i.e.: Someone telling you the correct syntax won't help you learn.)
As such, what you should do is:
Look at the ALTER TABLE syntax on MySQL.com
Make a copy of the table in question. (You can use a "CREATE TABLE <new table name> LIKE <existing table name>;
" to do this and populate it by using a "SELECT INTO <new table> FROM <old table>;
", etc. (Here's the SELECT INTO syntax.)
Try out your proposed ALTER TABLE on the copy to ensure it does what you want.
If it does (of indeed if it doesn't) you can use "DROP TABLE <new table name>;
" to dispose of the newly created table.
By doing this, you'll learn as you go which is a lot more valuable in the long run.
Upvotes: 5
Reputation: 22004
ADD [COLUMN] (col_name column_definition,...)
So can't you just separate each one of the parameters with comma.
ALTER TABLE users
ADD `user_id` varchar(16) DEFAULT NULL,
ADD `user_location` tinytext,
ADD `author_id` varchar(16) DEFAULT NULL;
Source: http://dev.mysql.com/doc/refman/5.5/en/alter-table.html
Upvotes: 1
Reputation: 1712
ALTER TABLE users ADD (
`user_id` varchar(16) DEFAULT NULL,
`user_location` tinytext,
`author_id` varchar(16) DEFAULT NULL);
Upvotes: 1