Rajesh Kumar G
Rajesh Kumar G

Reputation: 1534

Oracle : Unique Key and Primary Key

Consider the table which contains unique Key and Primary Key .the tables already contains data.If i added any rows to the table i received an error (ORA - 0001) which is due to the duplicate value is added to the Primary Key or Unique Key .Here i am not able to identify whether the error is due to the addition of duplicate value to the Primary Key or Unique Key.Can anyone suggest me how to identify this?

Upvotes: 1

Views: 1034

Answers (2)

APC
APC

Reputation: 146239

The format of the ORA-00001 message is:

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

where string.string is schema.constraint_name. This is why it is good practice to give our constraints helpful names.

create table t23
   ( id number not null
     , col1 varchar2(30)
     , col2 date
     , constraint t23_pk primary key (id)
     , constraint t23_uk unique (col1)
  )
/

Upvotes: 4

Chandu
Chandu

Reputation: 82923

The error displays the constraint that was violated . The message shd look like:

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

where (string.string) will be the name of the constraints

Upvotes: 2

Related Questions