Re: [GENERAL] ALTER TABLE -- how to add ON DELETE CASCADE?

2006-03-08 Thread Jim Nasby

On Mar 7, 2006, at 4:42 PM, [EMAIL PROTECTED] wrote:


On Tue, Mar 07, 2006 at 05:36:37PM -0500, Tom Lane wrote:

[EMAIL PROTECTED] writes:

ALTER TABLE A COLUMN AA ADD CONSTRAINT DELETE ON CASCADE


You're missing the specification of the foreign key, not to mention
spelling the CASCADE clause backwards.  Try

ALTER TABLE A ADD FOREIGN KEY(AA) REFERENCES B(BB) ON DELETE CASCADE


Got it right in the Subject: and my many attempts, just not in the
body :-)

The column already had the foreign key, I never thought to add it
again.  I was only thinking of modifying the minimum necessary.


Yeah, unfortunately there's no support for modifying constraints.
--
Jim C. Nasby, Sr. Engineering Consultant  [EMAIL PROTECTED]
Pervasive Software  http://pervasive.comwork: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf   cell: 512-569-9461



---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq


Re: [GENERAL] ALTER TABLE -- how to add ON DELETE CASCADE?

2006-03-08 Thread David Fetter
On Wed, Mar 08, 2006 at 04:06:55PM -0600, Jim Nasby wrote:
 On Mar 7, 2006, at 4:42 PM, [EMAIL PROTECTED] wrote:
 
 On Tue, Mar 07, 2006 at 05:36:37PM -0500, Tom Lane wrote:
 [EMAIL PROTECTED] writes:
 ALTER TABLE A COLUMN AA ADD CONSTRAINT DELETE ON CASCADE
 
 You're missing the specification of the foreign key, not to mention
 spelling the CASCADE clause backwards.  Try
 
 ALTER TABLE A ADD FOREIGN KEY(AA) REFERENCES B(BB) ON DELETE CASCADE
 
 Got it right in the Subject: and my many attempts, just not in the
 body :-)
 
 The column already had the foreign key, I never thought to add it
 again.  I was only thinking of modifying the minimum necessary.
 
 Yeah, unfortunately there's no support for modifying constraints.

Well, except in the sense of dropping and re-creating them inside a
transaction :)

Cheers,
D (transactional DDL is fantastic :)
-- 
David Fetter [EMAIL PROTECTED] http://fetter.org/
phone: +1 415 235 3778

Remember to vote!

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


[GENERAL] ALTER TABLE -- how to add ON DELETE CASCADE?

2006-03-07 Thread felix
I have table A with a column AA which references table B's primary
key BB, and I want to alter column AA to delete on cascade.

ALTER TABLE A COLUMN AA ADD CONSTRAINT DELETE ON CASCADE

is what I tried with a zillion variations, all reporting syntax
errors.

\h alter table seems to be missing any way to add a constraint to a
column.

Or maybe this isn't a constraint ... does seem like maybe the wrong
name, but I can't think what else it would be called, and the other
choices shown with \h seem even less likely.

Your assiatnce is much appreciated.  I would gladly send you some
Oreos or Ginger Nuts :-)

-- 
... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
 Felix Finch: scarecrow repairman  rocket surgeon / [EMAIL PROTECTED]
  GPG = E987 4493 C860 246C 3B1E  6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


Re: [GENERAL] ALTER TABLE -- how to add ON DELETE CASCADE?

2006-03-07 Thread Tom Lane
[EMAIL PROTECTED] writes:
 ALTER TABLE A COLUMN AA ADD CONSTRAINT DELETE ON CASCADE

You're missing the specification of the foreign key, not to mention
spelling the CASCADE clause backwards.  Try

ALTER TABLE A ADD FOREIGN KEY(AA) REFERENCES B(BB) ON DELETE CASCADE

 \h alter table seems to be missing any way to add a constraint to a
 column.

It's there, though you have to look to \h create table to see the
alternatives for table_constraint.

regards, tom lane

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [GENERAL] ALTER TABLE -- how to add ON DELETE CASCADE?

2006-03-07 Thread felix
On Tue, Mar 07, 2006 at 05:36:37PM -0500, Tom Lane wrote:
 [EMAIL PROTECTED] writes:
  ALTER TABLE A COLUMN AA ADD CONSTRAINT DELETE ON CASCADE
 
 You're missing the specification of the foreign key, not to mention
 spelling the CASCADE clause backwards.  Try
 
 ALTER TABLE A ADD FOREIGN KEY(AA) REFERENCES B(BB) ON DELETE CASCADE

Got it right in the Subject: and my many attempts, just not in the
body :-)

The column already had the foreign key, I never thought to add it
again.  I was only thinking of modifying the minimum necessary.

Thanks.

-- 
... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
 Felix Finch: scarecrow repairman  rocket surgeon / [EMAIL PROTECTED]
  GPG = E987 4493 C860 246C 3B1E  6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o

---(end of broadcast)---
TIP 6: explain analyze is your friend