I have an ancient code snippet I use for copying tables in MySQL.
CREATE TABLE new_table (select * from old_table);
This works great, with one exception. It doesn’t copy the primary key or other table indexes.
Is there any way to copy a table in MySQL AND include the indexes/primary key??
Theres one of two ways. To see how a table is built you can use
You could also (I think you’ll have to test it), run this: