How to move a MySQL table from one database to another

Practice



Task: move a table from one database to another in MySQL. For example, you created a table in the wrong database and, for whatever reason, don't want to recreate it.

The MySQL RENAME TABLE command will help us here:

RENAME TABLE database1.mytable TO database2.mytable

This moves the table from the database1 database to database2.
Applies to: MySQL 5+

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Databases - MySql (Maria DB)"

Terms: Databases - MySql (Maria DB)