在A表中,如果存在,就覆盖,如果没有,就插入
create table NC_USER_PHOTO
(
userid VARCHAR2(20) not null,
photo180 VARCHAR2(500),
photo100 VARCHAR2(500),
photo60 VARCHAR2(500),
photo30 VARCHAR2(500)
)
merge into nc_user_photo a
using (select '13'as userid, '121111' as photo180, '121' as photo100, '121' as photo60, '121' as photo30 from dual) b
on (a.userid=b.userid)
WHEN MATCHED THEN
update set a.photo180=b.photo180,a.photo100=b.photo100,a.photo60=b.photo60,a.photo30=b.photo30
WHEN NOT MATCHED THEN
insert(userid,photo180,photo100,photo60,photo30) values(b.userid,b.photo180,b.photo100,b.photo60,b.photo30)
Oracle中merge into的使用
来自:http://www.cnblogs.com/highriver/archive/2011/08/02/2125043.html
Merge 同一个表进行操作
来自:http://www.itpub.net/thread-508254-1-1.html