MERGE table, do nothing when matched

后端 未结 2 1487
遥遥无期
遥遥无期 2021-01-18 14:13

I have a table DOMAINS in 2 different schemas with columns ID, NAME,CODE,DESCRIPTION.

For any

2条回答
  •  孤独总比滥情好
    2021-01-18 14:45

    Oracle SQL syntax supports not having any when matched then update clause.

    drop table ft purge;
    create table ft (c1 number, c2 varchar2(10));
    
    drop table ld purge;
    create table ld (c1 number, c2 varchar2(10));
    
    insert into ft values (1,'a');
    insert into ld values (1,'b');
    insert into ld values (2,'c');
    commit;
    
    merge into ft 
    using ld
    on (ft.c1 = ld.c1) 
    when not matched then
    insert (c1,c2) values (ld.c1,ld.c2);
    
    select * from ft;
    
    C1  C2
    --- ---
    1   a
    2   c
    
    2 rows selected.
    

提交回复
热议问题