MySQL - Duplicate a table, including indexes, triggers, and data
Duplicate a table, including indexes, triggers, and data in MySQL
To duplicate table with indexes and triggers:
CREATE TABLE new_table LIKE old_table;
INSERT new_table SELECT * FROM old_table;
To duplicate table with just structure and data:
CREATE TABLE new_table AS SELECT * FROM old_table;
Need a good GUI Tool for MySQL? TablePlus is a modern, native tool with an elegant UI that allows you to simultaneously manage multiple databases such as MySQL, PostgreSQL, SQLite, Microsoft SQL Server and more.
Not on Mac? Download TablePlus for Windows.
On Linux? Download TablePlus for Linux
Need a quick edit on the go? Download TablePlus for iOS.