Re: How can I delete a primary or foreign key? - Mailing list pgsql-general

From tibor
Subject Re: How can I delete a primary or foreign key?
Date
Msg-id 200402201704.38773@newid
Whole thread Raw
In response to Re: How can I delete a primary or foreign key?  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Responses Re: How can I delete a primary or foreign key?  ("Joshua D. Drake" <jd@commandprompt.com>)
Re: How can I delete a primary or foreign key?  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Re: How can I delete a primary or foreign key?  (Richard Huxton <dev@archonet.com>)
Re: How can I delete a primary or foreign key?  (Adrian Klaver <aklaver@comcast.net>)
List pgsql-general
I forgot to mention that I have tried numerous variations.
The one quoted in the original mail was from "The Complete Reference" series.
I've also tried the one that the \h command suggests:

ALTER TABLE PARENTS DROP CONSTRAINT FOREIGN KEY (TYPE) CASCADE;

but all I got was:

ERROR:  syntax error at or near "foreign" at character 37

the DROP CONSTRAINT clause doesn't recognise either PRIMARY or FOREIGN KEY
option. (not implemented, I guess)

On Friday 20 Feb 2004 16:42, you wrote:
> On Fri, 20 Feb 2004, Tibor wrote:
> > I am using PostgreSQL 7.4.1 (only through psql)
> > I know, that the command
> >
> > ALTER TABLE OFFICES
> >     DROP PRIMARY KEY (CITY);
> >
> > and its foreign key equivalent:
> >
> > ALTER TABLE SALESREPS
> >     DROP CONSTRAINT
> > FOREIGN KEY (REP_OFFICE)
> >     REFERENCES OFFICES;
> >
> > don't work in PostgreSQL because they are not implemented. However, isn't
> > there another way of removing them?
>
> That's not the correct syntax for ALTER TABLE ... DROP CONSTRAINT.
>
> ALTER TABLE tablename DROP CONSTRAINT constraint_name [RESTRICT | CASCADE]

--
Tibor

pgsql-general by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: How can I delete a primary or foreign key?
Next
From: "Joshua D. Drake"
Date:
Subject: Re: How can I delete a primary or foreign key?