哈哈 谢谢大家,好久之前提的问题了。
我觉得这几个方案都可以吧
1.给B表加个int字段,值的含义:null 表示没更新过;0表示更新过但是更新失败;1表示更新成功
2.insert into a (字段)
select 字段 from b where not exists (select 1 from a where a.条件= b.条件)
3.merge into
如果拷贝数据后两张表的主键id确认相同:
insert into 表2(字段1,字段2,...)
select * from (
select *
from 表1 t1 left join 表2 t2
on t1.id = t2.id
where t2.id is null) da
表1是源数据表,表2是拷贝表。如果两张表的id无法一一对应,就将join on后面的条件改成其余字段的比较