And to go one step further with his question, I would like to know how to do
the following:

2 tables named table1 and table2

table1 contains 3 records, firstname, lastname, password.

table2 is the same except that it has one more field at the beginning and
that field is of type serial.

Now, I'd like to quickly select * from from table1 and insert it into table2
but each time issuing a nextval('sequence') on each one to update the
sequence numbers for table2.

This is because I made a bad design decision and decided I needed to have a
numerical identifier for each table entry, but the only way I know to do it
now would be to manually insert, or to write a php script to do it.  I
actually did end up doing the php script, but would like to know how else to
do it in the future for anything where I'm trying to take the contents of
one table and insert it into another table that has a different structure.

Thanks a lot.  Peace.

-----Original Message-----
From: McShen [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 02, 2001 2:47 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] duplicate a table



how do i duplicate a table?
i tried
create table refer2 select * from refer;
create table refer2 as select * from refer;

they didn't work.
my mysql version is  mysql 3.22.28,



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to