pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jim C. Nasby <decibel@decibel.org>
To: Peter Hanson <lists@pkhanson.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Adding "on delete cascade" to all foreign key constraints
Date: Tue, 15 May 2007 20:38:09 -0500
Message-ID: <20070516013809.GH11533@nasby.net> (raw)
In-Reply-To: <200705151219.54324.lists@pkhanson.com>
References: <200705151219.54324.lists@pkhanson.com>

On Tue, May 15, 2007 at 12:19:54PM -0500, Peter Hanson wrote:
> Hello,
> 
> I was wondering if there's a fast way I can add "on delete cascade" to all 
> foreign key constraints in my database?  Maybe a quick update I can make 
> against the catalog possibly? Or is there a way I can query for all foreign 
> key constrains in the database and then I could write up a quick script to do 
> the updates for me.

You shouldn't go mucking about with the system tables unless absolutely
necessary. Instead, write a SELECT that outputs the appropriate syntax.
You could do that by querying the catalogs directly, but I think you'll
find the pg_user_foreign_keys view defined by
http://pgfoundry.org/projects/newsysviews to be most helpful.
-- 
Jim Nasby                                      decibel@decibel.org
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)



view thread (2+ messages)

Message-ID: <20070516013809.GH11533@nasby.net>
Permalink:  ../20070516013809.GH11533@nasby.net/
Also on:    postgresql.org/message-id/20070516013809.GH11533@nasby.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: decibel@decibel.org, lists@pkhanson.com
  Subject: Re: Adding "on delete cascade" to all foreign key constraints
  In-Reply-To: <20070516013809.GH11533@nasby.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox