move table to different database

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
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

move table to different database

Post by neophyte »

In my mysql server, Table 'links' is in Database 'polls' I need to move table 'links' to database 'website' in the same mysql server. Does anyone know how to do this?

Thanks
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

1. Create the new table (links) in database website with the same structure as the links table in polls.
2. INSERT INTO website.links SELECT * FROM polls.links;
3. DROP TABLE polls.links; //this does the move rather than just a copy
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

I'll give it a try

Post by neophyte »

Thanks, I'll give it a try
Post Reply