tags:

views:

17

answers:

1

How do I copy / clone / duplicate the data, structure and indexes of a MySQL table to a new one?

This is what I've found so far.

This will copy the data and the structure, but not the indexes:

create table {new_table} select * from {old_table};

This will copy the structure and indexes, but not the data:

create table {new_table} like {old_table};
+2  A: 

need to do this in 2 lines,

create table newtable like oldtable; 
insert newtable select * from oldtable

i ask this before :

http://stackoverflow.com/questions/2415855/run-mysql-create-table-by-select-another-and-copied-the-indexes-automatically

Haim Evgi