Oracle:唯一密钥和主键

时间:2010-12-24 09:05:00

标签: oracle ora-00001

考虑包含唯一密钥和主密钥的表。这些表已经包含数据。如果我向表中添加任何行,我收​​到错误(ORA - 0001),这是由于重复值被添加到主键或唯一密钥。在这里我无法确定错误是否是由于向主键或唯一密钥添加重复值。任何人都建议我如何识别它?

2 个答案:

答案 0 :(得分:4)

ORA-00001 message的格式为:

ORA-00001:违反了唯一约束(string.string)

其中string.stringschema.constraint_name。这就是为什么优良做法为我们的约束提供有用的名称。

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

答案 1 :(得分:2)

错误显示违反的约束。 消息shd看起来像:

  

ORA-00001:唯一约束   (string.string)违反了

其中(string.string)将是约束的名称

相关问题