MySQL Forums
Forum List  »  InnoDB

Re: Alter table add unique
Posted by: Peter Brawley
Date: April 28, 2014 08:59AM

> Need to apply unique for that table and remove the rows which are duplicated.

You need to remove the dupes first. First examine them ...

select name,class,age,count(*)
from tbl
group by name,class,age
having count(*) > 1;

When you're sure, make a deletion query from that Select. Then alter the table.

Options: ReplyQuote


Subject
Views
Written By
Posted
1344
April 28, 2014 08:46AM
Re: Alter table add unique
667
April 28, 2014 08:59AM


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.