Wednesday, 25 July 2018

MySQL: Simplest way to move your InnoDB table from one Database to another Database

In this post, I am sharing a simple solution to move your InnoDB table from one database to another database in MySQL.
Before a few days ago, one of my team members was looking for this solution, and I found that many of Database Administrators do not know about this simple solution.
The solution is, we have to just rename the table name by specifying a database name.
The MySQL InnoDB engine has two types of tablespaces, one is a shared table space and second is an individual tablespace for each table.
This solution works for both the types of tablespaces.
Important Note: ibdata1 file or all .ibd file should be in one MySQL Data Directory at the same location.
After this demonstration, you can visit InnoDB Tablespace related articles.
Create TWO Sample Databases:
Create a sample table in database ABC:
Simplest way to move tbl_Students from database ABC to XYZ:
Check tbl_Students in XYZ database:

0 comments:

Post a Comment