从已有的表创建一个新的空表
CREATE TABLE new_table LIKE old_table;
注意: create table ... like 创建的表会保留原有表的字段、索引的定义,但不会保留外键的定义。
向空表插入数据
INSERT INTO new_table SELECT * FROM old_table;
参考链接:Create table in MySQL that matches another table? - Stack Overflow
CREATE TABLE new_table LIKE old_table;
注意: create table ... like 创建的表会保留原有表的字段、索引的定义,但不会保留外键的定义。
INSERT INTO new_table SELECT * FROM old_table;
参考链接:Create table in MySQL that matches another table? - Stack Overflow