如何将数据从转储文件插入到另一个具有不同数据结构的 table?

How to insert data from dump file to another table with different data structure?

我有两个 tables tb1(列 c1、c2、c3、c4、c5...)和 tb2(列 C1、C2、C3、C4、CN4、C5、CN6)、Tb2与 tb1 的模式描述相同,但我更改了 tb2 添加了更多列,我的问题是:我可以从 tb1 转储数据然后将其插入 tb2 即使 table 使用 mysqldump 进程有更多列吗?

除了从转储文件中插入,您还可以像下面那样执行 insert into ... select from。注意点:只有当 CN4CN6 是可为空的列(它们没有 not null 约束)时才有效。

insert into tb2(C1, C2, C3, C4, CN4, C5, CN6)
select C1, C2, C3, C4, null, C5, null
from tb1;