Click here to Skip to main content
15,909,591 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written below statement to declare my IFSC_CODE as unique, but below statement do not allow to declare it.

If anyone has solution please help me.
SQL
ALTER TABLE bank_master
add CONSTRAINT Ifsc_Code_unique UNIQUE (IFSC_CODE);
Posted
v2
Comments
Mukesh Ghosh 14-Aug-13 6:09am    
What kind of error you are getting?
Member 9410081 14-Aug-13 6:22am    
ORA-02299: cannot validate (TICL_NBFC.IFSC_CODE_UNIQUE) - duplicate keys found

From the Exception, it is quite clear that the Column already have duplicate values in it.
As you are altering the Table and making the Column UNIQUE, so it is violating.

If you want to make it UNIQUE, then try after removing the duplicate entries.
 
Share this answer
 
Here you are trying to create a Unique constraint.

Try creating a Non-unique index with a unique constraint and see if it works.
 
Share this answer
 
After reading all the comments and your query to alter the constraint and trying from my end.
I can say that the table which you are using is already having data (duplicate data)
and as per Unique key constraint all the values entered in that column must be unique
Null is also is unique but Null also can not be entered more than once
.
So i would suggest you delete all duplicate entries for that column and try.

Good luck
 
Share this answer
 
Try this.. :)
SQL
ALTER TABLE bank_master
ADD UNIQUE (IFSC_CODE);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900