MySQL - 重复表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/766928/
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
MySQL - Duplicate table
提问by Gerardo
I need to duplicate a table in MySQL, making the new table empty. That is, I need to copy only the structure of an existing table to a new one.
我需要在 MySQL 中复制一个表,使新表为空。也就是说,我只需要将现有表的结构复制到新表中。
回答by Brett Bender
Try the create table LIKE syntax.
尝试创建表 LIKE 语法。
create table users2 like users;
This should give you an empty table (users2) with the same structure as the original (users).
这应该为您提供一个与原始表(用户)具有相同结构的空表(用户 2)。
回答by Vineet1982
There is also another way to create a empty table as existing table and you can use the following command also
还有另一种方法可以创建一个空表作为现有表,您也可以使用以下命令
create table a select * from users2 limit 0, 0;