How to clone MySQL table
If you want to create a new MySQL table with the same structure as an existing table, you can use the following MySQL statement;
CREATE TABLE new_table LIKE source_table;
This will just create a new, empty table and does not copy the following;
-
Foreign key definitions
-
DATA DIRECTORY
-
INDEX DIRECTORY
-
Data
To also copy the data from the source table, use the following INSERT
statement after the table is created;
INSERT INTO new_table SELECT * FROM source_table;