Re: DELETING then INSERTING record with same PK in the same TRANSACTION

From: Thomas Kellerer <shammat(at)gmx(dot)net>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: DELETING then INSERTING record with same PK in the same TRANSACTION
Date: 2022-02-09 21:24:14
Message-ID: f4b2ad22-3b3c-e87c-a1d0-93643d0aaf3a@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David G. Johnston schrieb am 09.02.2022 um 21:47:
> You cannot defer uniqueness checks to transaction commit so either it
> is going to fail on the insert or it will not fail at all.

You can defer unique constraints, but not primary key constraints.

create table t
(
id integer
);

alter table t
add constraint unique_id
unique (id)
deferrable initially deferred;

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-02-09 22:23:01 Re: DELETING then INSERTING record with same PK in the same TRANSACTION
Previous Message Bryn Llewellyn 2022-02-09 21:20:49 Re: DELETING then INSERTING record with same PK in the same TRANSACTION