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