复制包含索引的 MySQL 表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2415855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 15:28:57 来源:igfitidea点击:
Copy a MySQL table including indexes
提问by Haim Evgi
I can copy a MySQL table to create a new table:
我可以复制一个 MySQL 表来创建一个新表:
CREATE TABLE newtable SELECT * FROM oldtable
This works, but the indexes are not copied to the new table. How can I copy a table including the indexes?
这有效,但索引不会复制到新表。如何复制包含索引的表?
回答by raveren
CREATE TABLE newtable LIKE oldtable;
INSERT INTO newtable SELECT * FROM oldtable;