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

oracle 避免重复插入数据

WBOY
Release: 2016-06-07 15:31:57
Original
2206 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template