Missing MySQL’s REPLACE (aka MERGE) in PostgreSQL

  2006-07-13


When Synthesys first decided to go with PostgreSQL as the database for a large web application, I was very excited to get away from our usual reliance on MySQL and move to a real database platform.

Once we figured out the whole MySQL auto_increment vs. PostgreSQL SERIAL, the first thing we really missed in PostgreSQL was the REPLACE statement. I understand why its missing, and it is kind of a hack of a SQL statement (its not in a SQL standard).

Turns out in the SQL 2003 Standard there is a statement similar to REPLACE called MERGE. Despite PostgreSQL’s excellent support for standards, they have not implemented MERGE. I would guess it has something to do with the ambiguity of the statement.

At any rate I still love working with PostgreSQL, and for what its worth Npgsql is an excellent PostgreSQL connector for Mono/.Net. (Even in RC/Beta state)