Posted on 2007-06-14 11:57
七郎归来 阅读(220)
评论(0) 编辑 收藏
create table t1(cid int,cname varchar2(100));
insert into t1 values (1,'1');
create table t2(cid int,cname varchar2(100));
insert into t2 values(1,'3');
insert into t2 values(2,'4');
MERGE INTO t1 a
USING t2 b
on (a.cid=b.cid)
WHEN MATCHED THEN
UPDATE SET a.cname=b.cname
WHEN NOT MATCHED THEN
INSERT (a.cid,a.cname ) VALUES ( b.cid,b.cname );