Home >Database >Mysql Tutorial >oracle 避免重复插入数据

oracle 避免重复插入数据

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 15:31:572217browse

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
    );

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn