Oto prosty przykład użycia merge:
create table a(id int, opis varchar2(10));
create table b(id int, opis varchar2(10));
insert into a values(1, 'zielony');
insert into a values(2, 'czerwony');
insert into a values(3, 'niebieski');
commit;
insert into b values(1, 'zielony');
insert into b values(2, 'brazowy');
insert into b values(3, 'niebieski');
insert into b values(4, 'szary');
commit;
merge into a
using (select * from b) b
on (a.id=b.id)
when matched then update set a.opis=b.opis
when not matched then insert (a.id, a.opis) values(b.id, b.opis);
Oczywiście zamiast bloku using (...) można użyć po prostu nazwy objektu. |