oracle 一般错误:1 OCIStmtExecute:ORA-00001:违反了唯一约束 (HR.SYS_C004023)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3881574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
General error: 1 OCIStmtExecute: ORA-00001: unique constraint (HR.SYS_C004023) violated?
提问by unni
I can identify the error message that its due to unique value constraint, my table is 'branches',and where did SYS_C004023 come. I have checked the branches table and there is no value duplication. What could be the issue.
我可以识别出由于唯一值约束而导致的错误消息,我的表是“分支”,SYS_C004023 是从哪里来的。我检查了分支表,没有值重复。可能是什么问题。
回答by Tony Andrews
where did SYS_C004023 come
SYS_C004023 哪来的
This is a system-generated constraint name, which Oracle creates when a constraint is created without being explicitly named e.g.
这是一个系统生成的约束名称,Oracle 在未明确命名的情况下创建约束时创建该名称,例如
create table mytable (col1 integer primary key);
The primary key constraint on mytable will be system-generated since I didn't explicitly name it like this:
mytable 上的主键约束将是系统生成的,因为我没有像这样明确地命名它:
create table mytable (col1 integer constraint mytable_pk primary key);
You can find out what table this constraint is on like this:
你可以像这样找出这个约束在哪个表上:
select table_name
from all_constraints
where owner = 'HR'
and constraint_name = 'SYS_C004023';
And you can find out which columns it makes unique like this:
您可以像这样找出哪些列是独一无二的:
select column_name
from all_cons_columns
where owner = 'HR'
and constraint_name = 'SYS_C004023';
there is no value duplication
没有价值重复
No, there won't be, thanks to the constraint. What there has been is a failed attemptto insert or update a row so that the uniqueness constraint is violatedd.
不,不会有,多亏了约束。所发生的是插入或更新行的尝试失败,从而违反了唯一性约束。