How are you determining the value to put in the Company_Id field? You
can use phpMyAdmin to easily add a column with a default/no null setting
to your tables to get you started. (It uses a MODIFY command I believe).

If you have the logic for determining the values of Company_ID, you
could do as you have suggested, but in multiple runs using LIMIT, or by
specifying incrementing ranges of the primary key for each table, so
that you don't blow out your RAM. Takes longer, but shouldn't crash your
server.

Andrew Hazen

-----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