From: | "fdu(dot)xiaojf(at)gmail(dot)com" <fdu(dot)xiaojf(at)gmail(dot)com> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | [TLM] How to insert on duplicate key? |
Date: | 2007-12-25 03:03:25 |
Message-ID: | 20071225030949.595E3414282@qatlm3.calidad2.pandasoftware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Glaesemann | 2007-12-25 03:20:26 | Re: How to insert on duplicate key? |
Previous Message | Michael Glaesemann | 2007-12-25 01:02:44 | Re: Postgres from PHP in Leopard |