开发者

How do I clone structure in MySQL?

开发者 https://www.devze.com 2023-02-20 16:44 出处:网络
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

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号