unable to drop a constraint

From: Enrico Sirola <enrico(dot)sirola(at)gmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org General" <pgsql-general(at)postgresql(dot)org>
Subject: unable to drop a constraint
Date: 2008-07-16 11:18:31
Message-ID: A2CF4BF9-4FC3-4A38-97C7-403D360EA512@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I'm using postgresql version 8.3.1

I have two tables, one has a field with a foreign key pointing to the
primary key of another table. When I to drop the first table, I get
the following error:

test=# drop table user;
ERROR: "customer_pkey" is an index

test=# select * from pg_constraint where conname like '%user%';
conname | connamespace | contype | condeferrable |
condeferred | conrelid | contypid | confrelid | confupdtype |
confdeltype | confmatchtype | conkey | confkey | conpfeqop | conppeqop
| conffeqop | conbin | consrc
--------------------+--------------+---------+---------------
+-------------+----------+----------+-----------+-------------
+-------------+---------------+--------+---------+-----------
+-----------+-----------+--------+--------
user_pkey | 137354 | p | f |
f | 137475 | 0 | 0 |
| | | {1} | |
| | | |
user_role_fkey | 137354 | f | f |
f | 137475 | 0 | 137463 | a |
a | u | {2} | {1} | {93} | {93}
| {93} | |
(2 rows)

so, I try to drop the foreign key constraint:

test=# alter table user DROP CONSTRAINT user_role_fkey;
ERROR: "customer_pkey" is an index

quite frustrated, I try to drop the pk index on the customer table:

test=# drop index customer_pkey ;
ERROR: cannot drop index customer_pkey because constraint
customer_pkey on table customer requires it
HINT: You can drop constraint customer_pkey on table customer instead.

test=# ALTER TABLE customer drop CONSTRAINT customer_pkey;
ERROR: "customer_pkey" is an index

I'm quite cunfused... Any idea?
Thanks,
e.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Viktor Rosenfeld 2008-07-16 13:06:49 Re: UPDATE runs slow in a transaction
Previous Message Greg Smith 2008-07-16 07:59:31 Re: [GENERAL] [pdxpug] Pg booth staffing at OSCON