Re: Temporarily disable not null constraints

From: Michael Lewis <mlewis(at)entrata(dot)com>
To: Nagaraj Raj <nagaraj(dot)sf(at)yahoo(dot)com>
Cc: Pgsql Performance <pgsql-performance(at)lists(dot)postgresql(dot)org>
Subject: Re: Temporarily disable not null constraints
Date: 2020-12-03 20:09:51
Message-ID: CAHOFxGp0iWnCGMMH3imUfoPVPq-_bS=qKKYHxtaA7uTUmhSe3g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, Dec 3, 2020 at 1:00 PM Nagaraj Raj <nagaraj(dot)sf(at)yahoo(dot)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.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Milos Babic 2020-12-03 20:13:46 Re: Temporarily disable not null constraints
Previous Message Nagaraj Raj 2020-12-03 19:58:15 Temporarily disable not null constraints