How do I clone structure in MySQL?
For example suppose I have a table M2011_03 and I wish to copy 开发者_如何学Gothe structure but not the data into a table M2011_04. M2011_04 currently does not exist. How do I do this?
I think you are looking for:
CREATE TABLE new_tbl LIKE orig_tbl;
More information: http://dev.mysql.com/doc/refman/5.1/en/create-table.html
either
a) paste the results of SHOW CREATE TABLE M2011_03
to create the '04 one.
or
b)
CREATE TABLE M2011_04 SELECT * FROM M2011_03;
TRUNCATE TABLE M2011_04;
精彩评论