欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

oracle 避免重复插入数据

程序员文章站 2022-05-30 12:54:55
...

using keyword :merge INTO ----------------------- merge into t1 using (select 1 a,3 b from dual) t2 on (t1.a = t2.a) when matched then update set t1.b = t1.bt2.b when not matched then insert (t1.a,t1.b) values(t2.a,t2.b) ------------------

using keyword :merge INTO

-----------------------

merge into t1 using (select 1 a,3 b from dual) t2
on (t1.a = t2.a)
when matched then update set t1.b = t1.b+t2.b
when not matched then insert (t1.a,t1.b) values(t2.a,t2.b)


------------------------------------

merge INTO SCNMON_DSMT_LV t1 USING
(SELECT 10916000 node_id FROM dual
) t2 ON (t1.lv_node_id = t2.node_id)
WHEN NOT matched THEN
INSERT
(
t1.lv_key,
t1.lv_node_id
)
VALUES
(
SEQ_SCNMON_DSMT_LV.nextval,
t2.node_id
);