> -----Original Message-----
> From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-
> owner@postgresql.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-enablethem. Look into table pg_constraint and function pg_get_constraintdef.
Dmitry Epstein | Developer
Allied Testing
www.alliedtesting.com
We Deliver Quality.