Page 1 of 1
Sending tables between databases
Posted: Wed Apr 26, 2006 11:04 am
by bwv2
I have one database with a bunch of big tables in it. I would like to separate it into 4 different databases by moving tables from the big database to the others that I will create.
Any thoughts on the easiest way of doing this?
Posted: Wed Apr 26, 2006 11:16 am
by feyd
Code: Select all
CREATE TABLE `newDatabase`.`newTable` LIKE `oldDatabase`.`oldTable`
Code: Select all
INSERT INTO `newDatabase`.`newTable` (`field1`, `field2`, .. `fieldn`) SELECT `field1`, `field2`, .. `fieldn` FROM `oldDatabase`.`oldTable`
Alternate way
Posted: Thu Apr 27, 2006 5:37 am
by dibyendrah
Without field can also be done if all fields are to be copied.
Code: Select all
INSERT INTO `database`.`new_table` SELECT * FROM `database`.`old_table` ;
Cheers,
Dibyendra