关联删除:

目的:删除掉A表中能关联B表的数据


delete from A as a
using B as b
where a.zd1=b.zd1

关联修改,关联新增

目的:当A表中数据能关联B表时,修改A表中数据为B表数据,当关联不到时,在A表1中新增B表数据

MERGE INTO  A as  a
USING  B  as  b
ON a.zd1=b.zd1
WHEN MATCHED THEN   --当关联上时,修改
UPDATE SET  a.zd2=b.zd2
WHEN NOT MATCHED THEN  --当关联不上时,新增
INSERT (zd1,zd2) values(b.zd1,b.zd2);