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-21 10:01:23
Message-ID: 29F36C7C98AB09499B1A209D48EAA615B767F86C78@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: Friday, October 21, 2011 1:11 AM
> To: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] how to disable all pkey/fkey constraints globally
>
> Is there a simpler way than this to query the database for meta-data and get
> the constraint definitions?
>
> If I have the constraint name (which I do), I could store the constraint
> definition to a file or database table and recreate them if I could get the
> definition.
>
> This seems like a very simple thing to do, but nowhere can I find the meta-
> data I would need to first save the constraint, to later re-create it.
>
> thanks

If you know constraint name and schema, then I don't see how you could possibly make it any simpler than the way I already suggested:

> >> Look into table pg_constraint and function pg_get_constraintdef.

Of course, since this involves the use of a system catalogue, this is neither portable nor very reliable in the long run. You can also get all the information about foreign key constraints from information_schema tables, but that is more complicated. You'll need to join table_constraints, referential_constraints and key_column_usage, probably more than once.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message The Great SunWuKung 2011-10-21 10:05:53 Re:
Previous Message Gashi, Ilir 2011-10-21 08:54:08 Re: Reading PG data from MySQL stored procedure