By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,696 Members | 1,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,696 IT Pros & Developers. It's quick & easy.

Unique Constraint Violation

P: 1
Why Unique Constraint Violation Takes Place In Oracle? How This Problen Can Be Solved?
Dec 27 '07 #1
Share this Question
Share on Google+
3 Replies


amitpatel66
Expert 100+
P: 2,367
Why Unique Constraint Violation Takes Place In Oracle? How This Problen Can Be Solved?
Hi Trinanjan,

Welcome to TSDN!!

Please make sure you follow POSTING GUIDELINES every time you post in this forum

Thanks
MODERATOR
Dec 27 '07 #2

amitpatel66
Expert 100+
P: 2,367
Why Unique Constraint Violation Takes Place In Oracle? How This Problen Can Be Solved?
Unique Constraint violation takes place when you try to insert a same value in a particular column that already exists.

Check this:

Expand|Select|Wrap|Line Numbers
  1. SQL> create table abcd(a NUMBER UNIQUE);
  2.  
  3. Table created.
  4.  
  5. SQL> insert into abcd values(1);
  6.  
  7. 1 row created.
  8.  
  9. SQL> /
  10. insert into abcd values(1)
  11. *
  12. ERROR at line 1:
  13. ORA-00001: unique constraint (APPS.SYS_C00157910) violated
  14.  
  15.  
  16. SQL> ed
  17. Wrote file afiedt.buf
  18.  
  19.   1* insert into abcd values(NULL)
  20. SQL> /
  21.  
  22. 1 row created.
  23.  
  24. SQL> /
  25.  
  26. 1 row created.
  27.  
  28. SQL> /
  29.  
  30. 1 row created.
  31.  
  32. SQL> 
  33.  
  34.  
Any number of NULLS can be inserted but not the same value.
Dec 27 '07 #3

debasisdas
Expert 5K+
P: 8,127
Why Unique Constraint Violation Takes Place In Oracle? How This Problen Can Be Solved?
It occurs to maintain data integrity .
To solve this u need to check for existance of data in a unique / Primay key field before inserting or updating the records.
Dec 27 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.