Re: how to disable all pkey/fkey constraints globally

From: <depstein(at)alliedtesting(dot)com>
To: <jvsrvcs(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: how to disable all pkey/fkey constraints globally
Date: 2011-10-05 08:49:59
Message-ID: 29F36C7C98AB09499B1A209D48EAA615B7653DBDB1@mail2a.alliedtesting.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-
> owner(at)postgresql(dot)org] On Behalf Of J.V.
> Sent: Tuesday, October 04, 2011 10:00 PM
> To: pgsql-general
> Subject: [GENERAL] how to disable all pkey/fkey constraints globally
>
> Is there a generic way to drop just all primary key and foreign key constraints
> on a given table?
>
> I know how to do given the specific name of the constraint.
>
> same question but one statement that would just disable all primary key and
> foreign key constraints on a given database?
>
> and am assuming the reverse could not be done because would have to re-
> create each one individually?
>
> Maybe I do not want to drop, so is there a way to simply disable all globally
> (not drop) & then enable all globally?
>

You can find all foreign key constraints for a given table, save constraint definitions, drop constraints, and later re-enable them. Look into table pg_constraint and function pg_get_constraintdef.

Dmitry Epstein | Developer

Allied Testing

www.alliedtesting.com
We Deliver Quality.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Abbate 2011-10-05 09:27:10 Re: how to disable all pkey/fkey constraints globally
Previous Message khizer 2011-10-05 08:46:18 Postgresql-8.2 Replication