Anuj Kumar
Anuj Kumar

Reputation: 314

Making a unique attribute in an already existing table NOT unique - MYSQL

A non-unique attribute of a table can be made unique by the query:

ALTER TABLE mytbl ADD UNIQUE (columnName);

I need to set a already unique attribute of a table NON-unique. Can anyone help me with the query?

Upvotes: 3

Views: 489

Answers (4)

Vyktor
Vyktor

Reputation: 21007

First of all you want to get name of index, you can do that by SHOW INDEX IN mytbl, then you can just ALTER TABLE:

ALTER TABLE mytbl DROP INDEX auto_index_name;

Upvotes: 0

Ajith Sasidharan
Ajith Sasidharan

Reputation: 1155

alter table mytbl drop index columnName;

Use the above command for the same.

Upvotes: 2

itinance
itinance

Reputation: 12428

you can drop the unique index with the following statement:

ALTER TABLE mytbl DROP INDEX columnName

Upvotes: 1

Mahmoud Gamal
Mahmoud Gamal

Reputation: 79979

Drop it, like so:

 ALTER TABLE yourTable DROP INDEX ItsName;

SQL Fiddle Demo

Upvotes: 1

Related Questions