1

I have a table (DBC) with a primary key and unique constraint. The unique constraint consists of two fields, a foreign key to an other table (Client) and a date.

The unique constraint was created with the following statement.

alter table DBC
     add constraint UNQ_DBC_CLIENT_STARTDATUM unique (FK_CLIENT, START_DATUM);

The unique constraint was just there to ensure that there where no duplicates in the database, it has never been used in a foreign key.

Now when I want to drop the unique constraint I always get the error

Cannot drop index 'UNQ_DBC_CLIENT_STARTDATUM': 
needed in a foreign key constraint. 

I tried all suggestions (drop key, drop index, alter table etc) I could find but without succes.

Any suggestions ?

John Woo
  • 258,903
  • 69
  • 498
  • 492
  • try to remove both columns index separately – xkeshav Aug 06 '12 at 08:31
  • 2
    You have to remove the foreign key first. Note that the foreign key will be defined on a different table, so you'll first have to find out which table that is. – Mark Byers Aug 06 '12 at 08:32
  • possible duplicate of [MySQL Cannot drop index needed in a foreign key constraint](http://stackoverflow.com/questions/8482346/mysql-cannot-drop-index-needed-in-a-foreign-key-constraint) – laffuste Feb 11 '14 at 04:56

0 Answers0