Tuesday, December 15, 2009

Merge statment in oracle

Merge statment in oracle
========================


drop table emp1;

create table emp1 as select * from emp ;


drop table dept1;

create table dept1 as select * from dept;


MERGE INTO emp1 a
USING dept1 b
ON (a.deptno = b.deptno)
WHEN MATCHED THEN
UPDATE SET a.sal = b.deptno
WHEN NOT MATCHED THEN
INSERT (empno, sal)
VALUES (b.deptno,b.deptno);

No comments: