Migrating an Oracle MERGE statement to a PostgreSQL UPSERT statement
问题 Can you please help me converting the following Oracle MERGE statement into a valid UPSERT statement for use in a PostgreSQL 9.3 database? MERGE INTO my_table a USING (SELECT v_c1 key, v_c2 AS pkey, v_c3 AS wcount, v_c4 AS dcount FROM DUAL) b ON ( a.key = b.key AND a.pkey = b.pkey WHEN MATCHED THEN UPDATE SET wcount = b.wcount, dcount = b.dcount WHEN NOT MATCHED THEN INSERT (key, pkey, wcount, dcount) VALUES(b.key,b.pkey,b.wcount,b.dcount); 回答1: I don't think there's UPSERT statement in