Monday, May 16, 2011

three handy mysql table operation

1. replicate a table & its data

create table new_table as select * from old_table

However, keep in mind that the new_table is myisam! So if your old_table is innodb, the new_table won't contain the key constraints

2. copy a table structure only (without its data)

create table new_table like old_table

3.rename a table

rename table old_table to new_table

No comments: