pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Adding "on delete cascade" to all foreign key constraints
2+ messages / 2 participants
[nested] [flat]

* Adding "on delete cascade" to all foreign key constraints
@ 2007-05-15 17:19 Peter Hanson <lists@pkhanson.com>
  2007-05-16 01:38 ` Re: Adding "on delete cascade" to all foreign key constraints Jim C. Nasby <decibel@decibel.org>
  0 siblings, 1 reply; 2+ messages in thread

From: Peter Hanson @ 2007-05-15 17:19 UTC (permalink / raw)
  To: pgsql-sql

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.

Any help is appreciated, TIA,

Pete Hanson




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Adding "on delete cascade" to all foreign key constraints
  2007-05-15 17:19 Adding "on delete cascade" to all foreign key constraints Peter Hanson <lists@pkhanson.com>
@ 2007-05-16 01:38 ` Jim C. Nasby <decibel@decibel.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Jim C. Nasby @ 2007-05-16 01:38 UTC (permalink / raw)
  To: Peter Hanson <lists@pkhanson.com>; +Cc: pgsql-sql

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)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2007-05-16 01:38 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-05-15 17:19 Adding "on delete cascade" to all foreign key constraints Peter Hanson <lists@pkhanson.com>
2007-05-16 01:38 ` Jim C. Nasby <decibel@decibel.org>

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