From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Dan Langille <dan(at)langille(dot)org> |
Cc: | <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: 7.4 - TODO : alter table drop foreign key |
Date: | 2002-12-05 17:31:15 |
Message-ID: | 20021205092252.D2582-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, 5 Dec 2002, Dan Langille wrote:
> On 5 Dec 2002 at 9:02, Stephan Szabo wrote:
>
> > On Thu, 5 Dec 2002, Dan Langille wrote:
> >
> > > Found the solution:
> > >
> > > drop trigger "RI_ConstraintTrigger_4278488" on watch_list_staging;
> >
> > Actually there are three triggers for the constraint. You may have
> > dangling triggers on the other table of the constraint. It's one on the
> > table the constraint's defined on and two on the referenced table.
> >
> > > Given that the FK in question did not have a name to start with, I
> > > concede that it would be difficult to code DROP FOREIGN KEY.
> > >
> > > What about supporting ALTER TABLE <table> ADD FOREIGN KEY <keyname>
> > > ... which at present we don't? That would then make dropping the FK
> > > a simple coding issue?
> >
> > ISTM, that's
> > ALTER TABLE <table> ADD CONSTRAINT <name> FOREIGN KEY ...
> > which should be there in any 7.x.
>
> Agreed. But the syntax is different. If we are supporting "ALTER
> TABLE <table> ADD FOREIGN KEY " without a name, why not support it
> with a name?
When we talk about ALTER TABLE ADD FOREIGN KEY we're being imprecise, so
I think that might be why we're talking past each other here.
Technically the syntax in question is:
ALTER TABLE <table> ADD <table constraint definition>
where CONSTRAINT <name> is an optional leading clause in a table
constraint definition. ADD FOREIGN KEY is a shorthand for a foreign key
constraint (technically unnamed).
Thus you can also say things like:
ALTER TABLE <table> ADD CONSTRAINT blah CHECK (foo!=0);
to make a named check constraint.
From | Date | Subject | |
---|---|---|---|
Next Message | Dan Langille | 2002-12-05 17:41:29 | Re: 7.4 - TODO : alter table drop foreign key |
Previous Message | Dan Langille | 2002-12-05 17:15:53 | Re: 7.4 - TODO : alter table drop foreign key |