Replicating a mysql table structure

by blowfish

Just found out that as of mysql4.1 you can actually replicate a whole table structure (with no data, so cool!) with the command :

create <new-table> like <old-table>;

Just that!

An older method is to attach a select statement to the create command like so :

create <new-table> select * from <old-table>;

This will actually create a copy of the old table as the new table. If you dont want to move data, then :

create <new-table> select * from <old-table> where 1=0;

For all these methods however, table indexes are not copied.