Re: Adding "on delete cascade" after table creation ?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Peter Alberer <h9351252(at)obelix(dot)wu-wien(dot)ac(dot)at>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Adding "on delete cascade" after table creation ?
Date: 2002-09-19 15:06:18
Message-ID: 20020919080532.I27428-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Thu, 19 Sep 2002, Peter Alberer wrote:

> Hi there,
>
> i have a table that SHOULD look like this:
>
> create table lr_object_usage (
> lr_object_usage_id integer
> constraint
> lr_object_usage_lr_object_usage_id_pk
> primary key,
> lr_object_id integer
> constraint lr_object_usage_lr_object_id_fk
> references lr_objects(lr_object_id)
> on delete cascade,
> access_time timestamp,
> user_id integer
> constraint lr_object_usage_user_id_fk
> references users(user_id),
> status varchar(11),
> context integer
> constraint lr_object_usage_context_fk
> references
> lr_object_usage(lr_object_usage_id)
> ___ON DELETE CASCADE___
> );
>
> unfortunately i think that the table was created without the delete
> cascade in the last line (for the constraint
> lr_object_usage_context_fk). Is it somehow possible to add the delete
> cascade without recreating the table?

You'll probably have to manually remove the triggers for the foreign
key constraint (see techdocs.postgresql.org's fk primers for info) and
then use alter table add constraint.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2002-09-19 15:18:09 Re: Deadlock error!?
Previous Message Ian Harding 2002-09-19 14:47:16 Re: Memory Errors...