Search Postgresql Archives

Re: how to disable all pkey/fkey constraints globally

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/20/2011 05:10 PM, J.V. wrote:
> 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.

The metadata is all in the PostgreSQL catalogs.  One could write
PL/pgSQL (or other PL) functions to select all the info from the
catalogs into a simple text (SQL statement) format (e.g., ALTER TABLE
tbl ADD CONSTRAINT ...), and also to generate or execute the disabling
(ALTER TABLE tbl DROP CONSTRAINT ...) statements.

You may think it's very simple, but I can assure you that adding or
dropping constraints is not so easy because the ADDs and DROPs have to
be issued in an order that takes into account inter-table/constraint
dependencies (including, in the general case, constraints that are
inherited between tables).

Joe

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux