Duplicate a table in MySQL



Very simple!

Log on to your MySQL instance, and select the DB you table is in;

mysql> use mydatabase;

Create the new table with the same structure as your source;

mysql> CREATE TABLE mytable_new LIKE mytable;

Then copy all the content from your original table into your new one;

mysql> INSERT into mytable_new SELECT * FROM mytable;

You’re all done !

Easy right !?

Leave a comment