oracle中merge into用法解析

2021-09-09 05:57:46 字數 1031 閱讀 2860

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表但是有很多可選項

例子:

-- 可重複執行

alter table table1 nologging;

merge into table1 rc

using

(select concat(to_char(sysdate,'yyyymmddhh24mmss'),rownum)id_col,clumn1,clumn2,clumn3,clumn4

from table2

where credit_balance is not null and type<>8 and status = 2 and seq_no is not null)all_record

on (rc.seq_no=all_record.seq_pay_no)

when not matched then (

recharge_seq_no ,

clumn1 ,

clumn2 ,

clumn3 ,

clumn4 ,

recharge_channel

) values(

all_record.id_col,

all_record.clumn1,

all_record.clumn2,

all_record.clumn3,

all_record.clumn4);

commit;

alter table table1 logging;

詳見:

如何將批處理做成類流處理 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 ...