How can I add a new column to an existing database without disrupting the data?
Marcel.
How can I add a new column to an existing database without disrupting the data?
Marcel.
This should work for you:
ALTER TABLE table_name ADD new_column_name int unsigned not null AFTER column_name;
You can replace: "int unsigned not null" with whatever datatype you are using for the column. Also leaving off "AFTER column_name" inserts the column by default as the last column in your table.
Troy
This is the example:
ALTER TABLE table_name ADD COLUMN new_column VARCHAR (100);
Do any of you guys also know how to create a new Table of specified columns?
Cheers.
This should work for you:
CREATE TABLE table_name (
column_1 varchar(50),
column_2 text,
column_3 int(10)
);
You can just keep adding as many columns that you will need. Then substitute varchar(50), int(10) ect.. with whatever datatype you are going to be using.
If you want to add new columns later on to this table use any of the above examples in this message thread.
Some good documentation for MySQL can be found here:
http://www.mysql.com/documentation/
In addition a book that I have found very valuable is:
MySQL by Paul DuBois Publisher: New Riders
I want to add a link as a column in my table which will direct me to another page. Thanks
Just want to say thanks very much to all, useful info for what I had to do today.