Copy Or Moving Database(TABLE'S) to Another Database. HOW?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
khaki_monster
Forum Commoner
Posts: 73
Joined: Tue Oct 11, 2005 12:36 am
Location: Philippines
Contact:

Copy Or Moving Database(TABLE'S) to Another Database. HOW?

Post by khaki_monster »

hello!

need some database advise or tips on how to exactly copy/ move('contents of') a 'Table' from one Database,
to another Database.

tanx in advanced!


cheerz!
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Log in as root, then run a query like this:

Code: Select all

INSERT INTO newDatabase.newTable SELECT * FROM oldDatabase.oldTable
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
khaki_monster
Forum Commoner
Posts: 73
Joined: Tue Oct 11, 2005 12:36 am
Location: Philippines
Contact:

Post by khaki_monster »

do i have to lock the database before copying or moving them?

cheerz!
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

No, depending on your setup it may be desired to lock it first however.
User avatar
khaki_monster
Forum Commoner
Posts: 73
Joined: Tue Oct 11, 2005 12:36 am
Location: Philippines
Contact:

Post by khaki_monster »

hi again..

questions are:
- what if('I TRIED') another sets of records added to oldDatabase and pass each values to the newDatabase using same statement.

Code: Select all

INSERT INTO newDatabase.newTable SELECT * FROM oldDatabase.oldTable
result, the newDatabase.newTable was not update with the new records. why?

- do i have to empties('TRUNCATE Table tablenme') those tables in newDatabase before inserting the data's?

- is their anyway to optimize('Fast/ speed'up') copying/ moving the data's to another database?

please help :wink:

cheerz!
Post Reply