How to insert on duplicate key?

Поиск
Список
Период
Сортировка
От fdu.xiaojf@gmail.com
Тема How to insert on duplicate key?
Дата
Msg-id 477072FD.50101@gmail.com
обсуждение исходный текст
Ответы Re: How to insert on duplicate key?  (Michael Glaesemann <grzm@seespotcode.net>)
Re: How to insert on duplicate key?  (Greg Smith <gsmith@gregsmith.com>)
[TLM] Re: How to insert on duplicate key?  (Greg Smith <gsmith@gregsmith.com>)
Список 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,

В списке pgsql-general по дате отправления:

Предыдущее
От: Michael Glaesemann
Дата:
Сообщение: Re: Postgres from PHP in Leopard
Следующее
От: Michael Glaesemann
Дата:
Сообщение: Re: How to insert on duplicate key?