The easiest way to add a column is to get somebody else to do it.

Seriously, Use the "ALTER TABLE TableName ADD COLUMN Company_id INT UNSIGNED
NULL" command.
This syntax may be found in the MySQL manual in 6.5.4
http://www.mysql.com/doc/A/L/ALTER_TABLE.html ,or page 428 if you have
downloaded the "pdf" version.

I hope I have been of help. - Steve G.


-----Original Message-----
From: Ulrik Witschass [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 26, 2002 3:33 PM
To: [EMAIL PROTECTED]
Subject: Adding a Column to an existing table


Hi, I'm new to this list, hopefully, I can contribute some wisdom :)

At the moment, I have to update a large database to be multi-company-ready,
so I basically have to add a Column "Company_ID" to nearly each table.

What would be the easiest way to do this?

I already thought about running a "SELECT *" Query for each table, saving
the result in an Array (in PHP, btw, it's a webapplication), dropping the
table, creating the new table and looping through the data to insert the
data again. Problem is, that this puts a heavy task on the server, I tried
it on a local "crash"-server, and even with carefully planned setting and
unsetting of the arrays, it eats up the RAM since the arrays just get damn
big. And since I have to remote control the server and it is important that
the server is online nearly 24/7, I risk to crash the server without having
the physical option to reboot it until the next morning...a few hundred
kilometres away from my workplace...

Now I am looking into two things:

1) is there some kind of "MODIFY" query I can run???

2) or is it possible to dumb the database, drop it, create the new structure
and then write the dumb back in with some options that it ignores the
"CREATE TABLE" queries and that it doesn't check if the count of the values
matches the count of the columns? (error I get when I try to do it at the
moment).

3) another way...

As you can see, I am not THAT experienced with MySQL, so any help is greatly
appreciated!!!

Ulrik


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to