Re: Adding "on delete cascade" to all foreign key constraints

Поиск
Список
Период
Сортировка
От Jim C. Nasby
Тема Re: Adding "on delete cascade" to all foreign key constraints
Дата
Msg-id 20070516013809.GH11533@nasby.net
обсуждение исходный текст
Ответ на Adding "on delete cascade" to all foreign key constraints  (Peter Hanson <lists@pkhanson.com>)
Список 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)


В списке pgsql-sql по дате отправления:

Предыдущее
От: Rodrigo De León
Дата:
Сообщение: Re: SQL Query Validate Records Multiple Tables - Help Needed
Следующее
От: "Bart Degryse"
Дата:
Сообщение: Re: SQL Query Validate Records Multiple Tables - HelpNeeded