>語法
merge into 目標表 a
using 源表 b
on(a.條件字段1=b.條件字段1 and a.條件字段2=b.條件字段2 ……)
when matched then update set a.更新字段=b.字段
when not matched then insert into a(字段1,字段2……)values(值1,值2……)
>含義:判斷on內的條件,當條件滿足,對目標表進行更新操作;當條件不滿足,對目標表進行插入操作;
>注意:判斷的總次數=總 插入/更新 次數!= 總 插入/更新 記錄=源表b的記錄數
>舉例: