[TLM] How to insert on duplicate key? - Mailing list pgsql-general

From fdu.xiaojf@gmail.com
Subject [TLM] How to insert on duplicate key?
Date
Msg-id 20071225030949.595E3414282@qatlm3.calidad2.pandasoftware.com
Whole thread Raw
List pgsql-general
Hi all,

I have a table like this,
CREATE TABLE mytable(
a    varchar(40),
b    text,
c    text,
PRIMARY KEY (a, b)
);

What I want to do is:
     insert a record into a table, and when the record already
exists(according to the primary key), update it.

I know that there is a ON DUPLICATE clause with MySQL, so I'm wondering is
there a quick and clean way to do this in PostgreSQL ?

I have googled and currently the only way I can find is do query first and
then update or insert.

Thanks a lot.

Regards,

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

pgsql-general by date:

Previous
From: Ivan Sergio Borgonovo
Date:
Subject: [TLM] Re: batch insert/update
Next
From: 杨雪枫
Date:
Subject: [TLM] It's serious,Help!