Thursday, August 10, 2017

ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found

This error happens when there are duplicate records in your table. For example, you have an EMPLOYEE table,

firstName           lastName          id               title           department
----------------      ---------------     ----------     -----------   -------------
Eva                     Young               223            manager    HR
Eva                      Young              223            VP             HD
Tom                     Lee                   519            Sales         SA

create unique index uniqueemp on employee (firstName, lastName, id);

The above SQL will generate the error:

ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found

To fix this problem, you can do one of the followings.

1. Change the id of one of the Eva Young records to something else.
2. Delete one of the Eva Young record.
3. Remove the unique key word in the creating index SQL.

---------------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.


No comments:

Post a Comment