Oracle学习之merge

--使用merge语句
create table new as  select * from emp where 1=0;
insert into new (empno,ename) select empno,ename from emp where deptno=10;

merge into new n using emp e
on (n.empno=e.empno)
when matched then update set n.sal=e.sal
  when not matched then 
    insert (n.empno,n.ename,n.sal,n.comm)
    values (e.empno,e.ename,e.sal,e.comm);
    
    select * from new;

 

posted @ 2016-03-24 22:53  道心不可练  阅读(183)  评论(0编辑  收藏  举报