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

From Richard Huxton
Subject Re: How can I delete a primary or foreign key?
Date
Msg-id 200402201708.22599.dev@archonet.com
Whole thread Raw
In response to Re: How can I delete a primary or foreign key?  (tibor <tiborh@mail.datanet.hu>)
Responses Re: How can I delete a primary or foreign key?
List pgsql-general
On Friday 20 February 2004 16:04, tibor wrote:
> I forgot to mention that I have tried numerous variations.
> The one quoted in the original mail was from "The Complete Reference"

Which book is this?

Look in the SQL Command reference - ALTER TALBLE

> series. I've also tried the one that the \h command suggests:
>
> ALTER TABLE PARENTS DROP CONSTRAINT FOREIGN KEY (TYPE) CASCADE;

The \h says the same as the manuals:
ALTER TABLE [ ONLY ] table [ * ]
    DROP CONSTRAINT constraint_name [ RESTRICT | CASCADE ]

If you have a table called "mytab" and a foreign-key constraint called
"myfkey" then you would use

ALTER TABLE mytab DROP CONSTRAINT myfkey;

If your constaint has a generated name like $1 then you'll want to quote it
"$1"
--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: tibor
Date:
Subject: Re: How can I delete a primary or foreign key?
Next
From: tibor
Date:
Subject: Re: How can I delete a primary or foreign key?