Re: A way to duplicate data across databases

From: Date: Thu, 15 Feb 2001 23:38:33 +0000
Subject: Re: A way to duplicate data across databases
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-40021@lists.php.net to get a copy of this message
> I'm making a script that generates test sites usíng dummy data stored in one > MySql database ("uwebsitebase") > > Now, using php-scripting, I'm copying these data to a demo-database > ("uwebdemo"). The structure is the same - the same tables with the same > fields. Only difference will be that the copied data should get new primary > keys which are auto-incremented. No problem there. > > However, the process is tedious. I have tables that contains some 30 fields > and it's just a bore selecting all fields from one table, and then writing a > complete insert statement with all the fields except the PK. > > Is there an easier way? Remember 1) It's PHP 2) It's across databases. > > I have to script it, since I need the new keys on other places. Couldn't you just use MySQL dump to dump it all out and suck it back in?... Perhaps, after dumping it out once, you could find a way to script the changes you need to the dumped file. Another option -- I dunno about MySQL, but I think in PostgreSQL you could maybe alter the database known as "template1". PostgreSQL pretty much just copies that database to create a new one. WARNING: I've never tried this. I don't know that this is a supported feature of PostgreSQL. You should be very, very diligent and careful if you try this. -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#40021) next »