Oracle Upsert新增或更新

--upsert on 可以多个条件 不能更新on的列(name,age)
MERGE INTO TBL_TEST t  
USING (SELECT 12 AS name ,44 AS pid,22 AS age FROM DUAL) bb  
ON (t.name = bb.name AND t.age=bb.age)  
WHEN MATCHED THEN   
  UPDATE SET t.pid=bb.pid  
WHEN NOT MATCHED THEN  
  INSERT (NAME, PID,AGE) VALUES(12, 44,2);

 

posted @ 2024-03-27 11:28  洞玄巅峰  阅读(109)  评论(0编辑  收藏  举报