| From: | "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com> |
|---|---|
| To: | tibor <tiborh(at)mail(dot)datanet(dot)hu> |
| Cc: | PostreSQL General <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: How can I delete a primary or foreign key? |
| Date: | 2004-02-20 16:53:59 |
| Message-ID: | 40363BA7.1090300@commandprompt.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
tibor wrote:
> 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;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You are forgetting the name of the constraint.
Sincerely,
Joshua D. Drake
>
> 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]
>
>
--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - jd(at)commandprompt(dot)com - http://www.commandprompt.com
Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL
| Attachment | Content-Type | Size |
|---|---|---|
| jd.vcf | text/x-vcard | 640 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Stephan Szabo | 2004-02-20 17:00:03 | Re: How can I delete a primary or foreign key? |
| Previous Message | tibor | 2004-02-20 16:27:14 | Re: How can I delete a primary or foreign key? |