Think before you speak, read before you think.

mysql将一张表移动到另外的库中

现在有db1.table1表,现在要将它放到db2中,最简的方法是mysqldump导出,再导入。

另一种方法是

create table db2.table2 as select * from db1.table1;

结构,数据内容一致,但是不会复制索引以及外键

要保持完全一致,则两步操作,先复制表结构,再复制数据

create table db2.table2 like db1.table1;
insert into db2.table2 select * from db1.table1;

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *