URGENT: How to change ON CASCADE RESTRICT to DELETE?

Lists: pgsql-general
From: Robert <robert(at)robert(dot)cz>
To: pgsql-general(at)postgresql(dot)org
Subject: URGENT: How to change ON CASCADE RESTRICT to DELETE?
Date: 2003-07-02 07:13:59
Message-ID: 3F028637.4080202@robert.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi,

how can I change ON CASCADE RESTRICT to ON CASCADE DELETE? I need to
do it on my production database now (client is really complaining...)
and I dont see any DROP CONSTRAINT in the docs - whats the right and/or
simplest way? Thanks a lot

- Robert


From: "Kallol Nandi" <kallol(dot)nandi(at)indussoft(dot)com>
To: "Pgsql-General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: URGENT: How to change ON CASCADE RESTRICT to DELETE?
Date: 2003-07-02 08:02:24
Message-ID: NBEDKIHMDKLGDCDIJLMMKECFCBAA.kallol.nandi@indussoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


Drop constraint is there within Alter Table command.

Regards,
Kallol.

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Robert
Sent: Wednesday, July 02, 2003 12:44 PM
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] URGENT: How to change ON CASCADE RESTRICT to DELETE?

Hi,

how can I change ON CASCADE RESTRICT to ON CASCADE DELETE? I need to
do it on my production database now (client is really complaining...)
and I dont see any DROP CONSTRAINT in the docs - whats the right and/or
simplest way? Thanks a lot

- Robert

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Robert <robert(at)robert(dot)cz>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: URGENT: How to change ON CASCADE RESTRICT to DELETE?
Date: 2003-07-02 09:03:37
Message-ID: 20030702020230.N69957-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


On Wed, 2 Jul 2003, Robert wrote:

> Hi,
>
> how can I change ON CASCADE RESTRICT to ON CASCADE DELETE? I need to
> do it on my production database now (client is really complaining...)
> and I dont see any DROP CONSTRAINT in the docs - whats the right and/or
> simplest way? Thanks a lot

If you're using 7.3, you should IIRC be able to use alter table to drop
the constraint and then re-add it.

If you're using an older version, I think you may need to find the
triggers involved and drop those and then re-add the constraint. I think
techdocs has some info on finding the triggers.


From: Robert <robert(at)robert(dot)cz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: URGENT: How to change ON CASCADE RESTRICT to DELETE?
Date: 2003-07-02 10:14:34
Message-ID: 3F02B08A.9050303@robert.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Stephan Szabo wrote:

>> how can I change ON CASCADE RESTRICT to ON CASCADE DELETE? I need to
>>do it on my production database now (client is really complaining...)
>>and I dont see any DROP CONSTRAINT in the docs - whats the right and/or
>>simplest way? Thanks a lot
>>
>>
>
>If you're using 7.3, you should IIRC be able to use alter table to drop
>the constraint and then re-add it.
>
>If you're using an older version, I think you may need to find the
>triggers involved and drop those and then re-add the constraint. I think
>techdocs has some info on finding the triggers.
>
>
Tried ALTER TABLE (yes, this is 7.3) but \d says

nbcz=# \d seasons
Table "public.seasons"
Column | Type |
Modifiers
----------+---------+---------------------------------------------------------
id | integer | not null default
nextval('public.seasons_id_seq'::text)
hotel_id | integer |
name | text |
Indexes: seasons_pkey primary key btree (id)
Foreign Key constraints: $1 FOREIGN KEY (hotel_id) REFERENCES hotels(id)
ON UPDATE NO ACTION ON DELETE NO ACTION

and

ALTER TABLE seasons DROP CONSTRAINT $1;

didn't work. Apparently I'm more then a bit confused, but what's the
name of the constraint here? I finally took a deep breath, dropped the
database and edited dump directly. Now it seems to work, but I'd still
like to now the correct way (ALTER TABLE but how?) Thanks for your help

- Robert


From: Ian Barwick <barwick(at)gmx(dot)net>
To: Robert <robert(at)robert(dot)cz>, pgsql-general(at)postgresql(dot)org
Subject: Re: URGENT: How to change ON CASCADE RESTRICT to DELETE?
Date: 2003-07-02 10:35:45
Message-ID: 200307021235.45521.barwick@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


> ALTER TABLE seasons DROP CONSTRAINT $1;
>
> didn't work. Apparently I'm more then a bit confused, but what's the
> name of the constraint here?

ALTER TABLE seasons DROP CONSTRAINT "$1";

Ian Barwick
barwick(at)gmx(dot)net


From: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
To: Robert <robert(at)robert(dot)cz>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: URGENT: How to change ON CASCADE RESTRICT to DELETE?
Date: 2003-07-02 10:39:02
Message-ID: Pine.LNX.4.21.0307021137431.29474-100000@ponder.fairway2k.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, 2 Jul 2003, Robert wrote:

> Stephan Szabo wrote:
>
> >> how can I change ON CASCADE RESTRICT to ON CASCADE DELETE? I need to
> >>do it on my production database now (client is really complaining...)
> >>and I dont see any DROP CONSTRAINT in the docs - whats the right and/or
> >>simplest way? Thanks a lot
> >>
> >>
> >
> >If you're using 7.3, you should IIRC be able to use alter table to drop
> >the constraint and then re-add it.
> >
> >If you're using an older version, I think you may need to find the
> >triggers involved and drop those and then re-add the constraint. I think
> >techdocs has some info on finding the triggers.
> >
> >
> Tried ALTER TABLE (yes, this is 7.3) but \d says
>
> nbcz=# \d seasons
> Table "public.seasons"
> Column | Type |
> Modifiers
> ----------+---------+---------------------------------------------------------
> id | integer | not null default
> nextval('public.seasons_id_seq'::text)
> hotel_id | integer |
> name | text |
> Indexes: seasons_pkey primary key btree (id)
> Foreign Key constraints: $1 FOREIGN KEY (hotel_id) REFERENCES hotels(id)
> ON UPDATE NO ACTION ON DELETE NO ACTION
>
> and
>
> ALTER TABLE seasons DROP CONSTRAINT $1;
>
> didn't work. Apparently I'm more then a bit confused, but what's the
> name of the constraint here? I finally took a deep breath, dropped the
> database and edited dump directly. Now it seems to work, but I'd still
> like to now the correct way (ALTER TABLE but how?) Thanks for your help
>

I don't know about it being the correct way but isn't there entries in
pg_constraint that you can twiddle directly to change the cascade action?

--
Nigel J. Andrews


From: Kris Jurka <books(at)ejurka(dot)com>
To: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
Cc: Robert <robert(at)robert(dot)cz>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: URGENT: How to change ON CASCADE RESTRICT to DELETE?
Date: 2003-07-02 12:10:32
Message-ID: Pine.LNX.4.33.0307020806570.10939-100000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, 2 Jul 2003, Nigel J. Andrews wrote:

> On Wed, 2 Jul 2003, Robert wrote:
>
> > Stephan Szabo wrote:
> >
> > >> how can I change ON CASCADE RESTRICT to ON CASCADE DELETE? I need to
> > >>do it on my production database now (client is really complaining...)
> > >>and I dont see any DROP CONSTRAINT in the docs - whats the right and/or
> > >>simplest way? Thanks a lot
> > >>
> > >>
> > >
> > >If you're using 7.3, you should IIRC be able to use alter table to drop
> > >the constraint and then re-add it.
> > >
> > >If you're using an older version, I think you may need to find the
> > >triggers involved and drop those and then re-add the constraint. I think
> > >techdocs has some info on finding the triggers.
> > >
> > >
> > Tried ALTER TABLE (yes, this is 7.3) but \d says
> >
> > nbcz=# \d seasons
> > Table "public.seasons"
> > Column | Type |
> > Modifiers
> > ----------+---------+---------------------------------------------------------
> > id | integer | not null default
> > nextval('public.seasons_id_seq'::text)
> > hotel_id | integer |
> > name | text |
> > Indexes: seasons_pkey primary key btree (id)
> > Foreign Key constraints: $1 FOREIGN KEY (hotel_id) REFERENCES hotels(id)
> > ON UPDATE NO ACTION ON DELETE NO ACTION
> >
> > and
> >
> > ALTER TABLE seasons DROP CONSTRAINT $1;
> >
> > didn't work. Apparently I'm more then a bit confused, but what's the
> > name of the constraint here? I finally took a deep breath, dropped the
> > database and edited dump directly. Now it seems to work, but I'd still
> > like to now the correct way (ALTER TABLE but how?) Thanks for your help
> >
>
> I don't know about it being the correct way but isn't there entries in
> pg_constraint that you can twiddle directly to change the cascade action?
>

I don't think this is correct. I believe the function that the
referential integrity trigger points to (pg_trigger.tgfoid) is what
actually determies the RI action. The pg_constraint entry is just a
label of the action when it was constructed.

Kris Jurka