Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Adding a UNIQUE CONSTRAINT to an existing column with duplicate values

GSunMay 23 2013 — edited May 23 2013
Hello Oracle Forums, I have a table that contains 11,901 rows. I tried to define the UNIQUE constraint on the xcode column but received an error: the column already contain duplicate values! I issued following SQL 'SELECT COUNT(*) FROM states;' the result is 11,901 and 'SELECT COUNT(DISTINCT (xcode)) FROM states;' the result is 11,680. Hence to enforce this unique key I must remove the 221 rows. Please how can I achieve this?
This post has been answered by jeneesh on May 23 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 20 2013
Added on May 23 2013
5 comments
2,440 views