MySQL Forums
Forum List  »  Newbie

Re: ALTER TABLE DROP UNIQUE CONSTRAINT problem
Posted by: Felix Geerinckx
Date: June 28, 2005 04:12AM

Arun Venkatesan wrote:

> ALTER TABLE table_name DROP PRIMARY KEY; // This drops the first unique index, if there is no
> primary key defined.
>
> However, in the later version that I have with me (4.1.10), I get the following error when executing
> the above command:
>
> "ERROR 1091: Can't DROP 'PRIMARY'; check that column/key exists"
>
> Is there any other way to achieve this? Basically, how does one drop a unique constraint?


1) Find out the name of the index with SHOW INDEX FROM table_name (look in the Key_name column)
2) Then drop it: ALTER TABLE table_name DROP INDEX the_index

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
Re: ALTER TABLE DROP UNIQUE CONSTRAINT problem
June 28, 2005 04:12AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.