How to copy a table in MySQL
In MySQL, you can easily copy a table’s structure and data as follows.
Suppose you want to create table_new with the same structure and data as table_name. Follow these steps.
- Create the new table with this command.
CREATE TABLE table_new LIKE table_name;
The command above creates a table with the same structure as the original. 2. Copy data from the original table to the new table.
INSERT INTO table_new SELECT * FROM table_name;