Re: Temporarily disable not null constraints - Mailing list pgsql-performance

From Michael Lewis
Subject Re: Temporarily disable not null constraints
Date
Msg-id CAHOFxGp0iWnCGMMH3imUfoPVPq-_bS=qKKYHxtaA7uTUmhSe3g@mail.gmail.com
Whole thread Raw
In response to Temporarily disable not null constraints  (Nagaraj Raj <nagaraj.sf@yahoo.com>)
List pgsql-performance
On Thu, Dec 3, 2020 at 1:00 PM Nagaraj Raj <nagaraj.sf@yahoo.com> wrote:
Hi,

Can we disable not null constraints temporarily in the session-based transaction, like we disable FK constraints? 

SET session_replication_role = ‘replica’; 
alter table table_name disable trigger user;”

above two options are working for unique constraints violation exception. 

Thanks,
Rj


You can alter the column and remove the not null constraint, do your work, and then add it back, but it will have to verify all rows have that column set, that is, you can't leave some of them null.

pgsql-performance by date:

Previous
From: Nagaraj Raj
Date:
Subject: Temporarily disable not null constraints
Next
From: Milos Babic
Date:
Subject: Re: Temporarily disable not null constraints