喵喔喔
update set B b=A.b,c=A.c,d=A.d from A where B.a=A.a
insert into B(a,b,c,d) select A.a,A.b,A.c,A,d from A where A.a not in(select a from B)
for c in (select a,b,c,d from A left join B on A.a=B.a) loop
update B set b=c.b,c=c.c,d=c.d where a=c.a;
end loop;insert into B(a,b,c,d) select A.a,A.b,A.c,A,d from A where A.a not in(select a from B);
喵喵时光机
update set B b=A.b,c=A.c,d=A.d from A where B.a=A.a
insert into B(a,b,c,d) select A.a,A.b,A.c,A,d from A where A.a not in(select a from B)
for c in (select a,b,c,d from A left join B on A.a=B.a) loop
update B set b=c.b,c=c.c,d=c.d where a=c.a;
end loop;insert into B(a,b,c,d) select A.a,A.b,A.c,A,d from A where A.a not in(select a from B);