1

I cannot drop a constraint in postgres even using adminer

ALTER TABLE table_name
DROP CONSTRAINT constraint_name;

Error in query : ERROR: constraint "constraint_name" of relation "table_name" does not exist

but if I create a new one like :

ALTER TABLE table_name
ADD CONSTRAINT my_new_constraint(column1, column2, ... column_n);

Then it works and I can drop it.

The one who made the constraint I try to drop did it this way two years ago:

create unique index constraint_name on table_name (column1,lower(column2),coalesce(deleted_at,\'19000101\')

If anyone has got any idea to drop this constraint?

2
  • What is your intention here: coalesce(deleted_at,\'19000101\') ? Commented Jan 21, 2020 at 13:47
  • I have just tried to drop the index using this and it worked !!! Thank you ``` Commented Jan 21, 2020 at 13:50

1 Answer 1

2

CREATE UNIQUE INDEX creates an index that needs to be dropped with DROP INDEX, not a table constraint.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.