merge into 常用于联表更新
格式:
merge into ...
using (...)
on (...)
when matched then ...
when not matched then...
例如:A和B 匹配时更新,不匹配则插入
merge into A a
using (select * from B) b
on (a.id=b.id)
when matched then
update set a.name=b.name
when not matched then
insert (id,name)=(b.id,b.name)
注意:update 后没有表名
Insert 后没有into 表名