| От | Greg Stark |
|---|---|
| Тема | Re: Insert Or update |
| Дата | |
| Msg-id | 87n05238k7.fsf@stark.xeocode.com обсуждение исходный текст |
| Ответ на | Re: Insert Or update (Bruno Wolff III <bruno@wolff.to>) |
| Список | pgsql-general |
Bruno Wolff III <bruno@wolff.to> writes: > This was discussed on the list over the last couple of days. > There is no update or insert statement in postgres. > You can do an update and check the number of rows affected and if it > is 0 do the insert. I prefer to do the insert and if it fails due to a unique key constraint then do the update. If you don't have any deletes then this is safe from race conditions whereas the update first method could fail if two people do updates and then both try to insert. In practice actually I rarely have to do this. > However unless you lock the table while doing this, you have to be prepared > to handle errors. -- greg
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера