Oracle DML语句

作者: vubh | 来源:发表于2017-04-14 14:02 被阅读0次

1、Merge into

MERGE [INTO [schema .] table [t_alias] 
USING [schema .] { table | view | subquery } [t_alias] 
ON ( condition ) 
WHEN MATCHED THEN merge_update_clause 
WHEN NOT MATCHED THEN merge_insert_clause

merge into 表 
using {表,子查询结果集}
on (条件)
when matched then(匹配)
  update set users.user_name = doctor.doctorname
when not matched then(不匹配)
  insert  values('值1','值2',....)

merge into users
     using man
on (users.user_id = man.man_id)
when matched then
     update set users.user_name = man.man_name
when not matched then
     insert values  (man.man_id,man.man_name,'年龄',sysdate);

相关文章

网友评论

    本文标题:Oracle DML语句

    本文链接:https://www.haomeiwen.com/subject/yxmwattx.html