日期:2014-05-16  浏览次数:20459 次

用一张表来更新另一张表
经典语句:UPDATE TABLE1 SET (A, B, C) = (SELECT A, B, C FROM TABLE2)



? ORACLE:可以用MERGE语句(oracle 10g或以上),它是update和insert的组合.

?

MERGE INTO TABLE1 A

 USING TABLE2 B
  ON (A.OBJECT_ID = B.OBJECT_ID)
 WHEN MATCHED THEN
  UPDATE SET A.STATUS = B.STATUS
 WHEN NOT MATCHED THEN
  INSERT (OBJECT_ID, STATUS) VALUES (B.OBJECT_ID, B.STATUS)

?