Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy a MySQL table including indexes

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?

like image 673
Haim Evgi Avatar asked Mar 10 '10 09:03

Haim Evgi


People also ask

How do I copy a table from one schema to another in MySQL?

Right-click on the database name then select "Tasks" > "Export data..." from the object explorer. 4. Provide authentication and select the source from which you want to copy the data; click "Next".


1 Answers

CREATE TABLE newtable LIKE oldtable;  INSERT INTO newtable SELECT * FROM oldtable; 
like image 66
raveren Avatar answered Sep 22 '22 15:09

raveren