62
votes

I can copy a MySQL table to create a new table:

CREATE TABLE newtable SELECT * FROM oldtable

This works, but the indexes are not copied to the new table. How can I copy a table including the indexes?

1
indexes not create vs prevent the indexes is ambiguous, what do you want to do?Pentium10
@luchaninov the answer on that question mentions this question. This is an infinite loop.FrancescoMM

1 Answers

122
votes
CREATE TABLE newtable LIKE oldtable; 
INSERT INTO newtable SELECT * FROM oldtable;