Oracle Merge into

>語法

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的記錄數

>舉例:

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章