Thursday, April 10, 2008

ORA-00001: unique constraint

ORA-00001: unique constraint (string.string) violated

Cause: An UPDATE or INSERT statement attempted to insert a duplicate key. For Trusted Oracle configured in DBMS MAC mode, you may see this message if a duplicate entry exists at a different level.

Action: Either remove the unique restriction or do not insert the key.

This error is related to the duplicate data. Whenever you try to insert same unique/primary key you will encounter this error.

Example:

SQL> CREATE TABLE Employee (
2 EMP_ID VARCHAR(10) PRIMARY KEY,
3 name VARCHAR(20),
4 address VARCHAR(20)
5 );

Table created.

SQL>
SQL> INSERT INTO Employee VALUES ('0602751122','Sree Mendu','Cincinnati OH');

1 row created.

SQL> INSERT INTO Employee VALUES ('0602751122','Sree Ram','Cincinnati OH');
INSERT INTO Students VALUES ('0602751122','Sree Ram','Cincinnati OH')
*
ERROR at line 1:
ORA-00001: unique constraint (AGHT.SYS_C005092) violated

No comments: