Re: How can I use PHP to duplicate a mysql templatedatabase? [hack] bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



on 12/17/02 6:20 PM, Daevid Vincent at daevid@daevid.com appended the
following bits to my mbox:

> This method copies the data, but doesn't copy 'Extra' stuff like
> "auto_increment".

I've used the following before:

SHOW CREATE TABLE $tablename

You could probably do something like this.

1) Pick the database (SHOW DATABASES);

2) Create new database

3) List the tables in the database (SHOW TABLES FROM $database)

4) For each table in the database, do the following:

    a) SHOW CREATE TABLE $tablename
  
    b) perform the above query on the new database

    c) transfer the data

If the databases are on the same server, I think you can do (c) as the
following:

INSERT INTO $new_database.$tablename SELECT * FROM $old_database.$tablename;

If it's a remote server, I think it would require you to do it in PHP
(ouch).

Hope that helps.

Sincerely,

Paul Burney
<http://paulburney.com/>

<?php
    while ($self != "asleep") {
        $sheep_count++;
    }
?>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux