move table from one schema to another schema ?

I want to move table from one schema to another schema in mysql , can anybody tell me how can I do this .


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

If both schema is on same server then Alter table can be used to move tables from one db to another.

alter table old_db.fooTable rename new_db.fooTable

Method 2

Moving tables with space characters in between should be enclosed.


ALTER TABLE `schema1`.`tbl somename` 
RENAME TO  `schema2`.`tbl somename` ;

Method 3

Moving fooTable from old_db_schema to new_db_schema will be a 2 step process:

Step 1:

CREATE SCHEMA new_db_schema --Assuming you do not have new schema

Step 2:

ALTER SCHEMA new_db_schema
TRANSFER old_db_schema.fooTable 

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x