mysql复制表有两种方式,create table as
和create table like
,这二者仍是有差异,须要根据不一样的使用场景去选择
一、create table as
,能够复制表结构,但不能复制索引;能够在复制表结构的同时复制数据
复制表结构mysql
create TABLE new_table as select * from old_table where 1=0;
复制表结构和数据sql
create table new_table as select * from old_table;
二、create table like
,能够复制表结构和索引
复制表结构create table new_table like old_table;
segmentfault