代码改变世界

Oracle merge into

2013-11-23 15:21  waddell  阅读(226)  评论(0编辑  收藏  举报
--合并数据库 MERGE
--MERGE INTO table_name
--USING table_name
--ON (expressioin)
--WHEN MATCHED THEN
--     UPDATE SET …
--WHEN NOT MATCHED THEN
--     INSERT … VALUES…

MERGE INTO PERSION P1
USING PERSION02 P2
ON (P1.ID = P2.ID)
WHEN MATCHED THEN
    UPDATE SET P1.AGE = P2.AGE ;
WHEN NOT MATCHED THEN
    INSERT (P1.ID, P1.AGE) VALUES (P2.ID, P2.AGE);