oracle中merge into用法理解

2021-10-07 22:12:25 字數 729 閱讀 2452

merge into [target-table] a using [source-table sql] b on([conditional expression] and […]…)

when matched then

[update sql]

when not matched then

[insert sql]

作用:判斷b表和a表是否滿足on中條件,如果滿足則用b表去更新a表,如果不滿足,則將b表資料插入a表但是有很多可選項,如下:

1.正常模式

2.只update或者只insert

3.帶條件的update或帶條件的insert

4.全插入insert實現

5.帶delete的update(覺得可以用3來實現)

eg:merge into 表1 a using (select hh,xse,mle from zzjtwo.ml) b on (a.subbh=b.hh and a.fyear=『2020』 and a.fmonth=『6』)

when matched

then update set a.mle=nvl(a.mle,0)+nvl(b.mle,0),a.xse=nvl(a.xse,0)+nvl(b.xse,0)

when not matched

then insert (subbh,xse,mle,fyear,fmonth) values (b.hh,b.xse,b.mle,『2020』,『6』)

如何將批處理做成類流處理 merge into

例如 隨著人工智慧的不斷發展,機器學習這門技術也越來越重要,很多人都開啟了學習機器學習,本文就介紹了機器學習的基礎內容。需要在前端頁面上設計成實時的資料,但是沒有flink,所以只能把批處理做成類流處理 更新存在的 update employe as em set salary select sal...

oracle中累計求和 oracle累計求和

poj2001 shortest prefixes trie樹應用 沉迷wow又頹了兩天orz,暴雪爸爸要在國服出月卡了.這是要我好好學習嗎?趕緊來刷題了.oj 題目大意是求所有字串裡每乙個字元 硬體相關 jtag介面 jtag joint test action group,聯合測試行動小組 是一...

oracle中累計求和 oracle累計求和

oracle累計求和 將當前行某列的值與前面所有行的此列值相加,即累計求和 方法一 with t as select 1 val from dual union all select 3 from dual union all select 5 from dual union all select ...