merge into (select a,b,c,d from a) t1 using (select a,b,c,d from b) t2 on(t1.a=t2.a)when not matched theninsert (t1.a,t1.b,t1.c,t1.d)values (t2.a,t2.b,t2.c,t2.d);