错误ENA-02291完整性约束(SYSTEM.SYS_C005494)违反 - 未找到主键

时间:2017-09-23 20:34:38

标签: oracle oracle10g ora-02291

这是我的代码:

create table socio_recomendado(
cc_soc2 number(10) not null,
cc_socio_recomendado number(10) not null,
foreign key(cc_soc2)
references socio(cc_soc),
foreign key(cc_socio_recomendado)
references socio(cc_soc),
constraint C_SOC
check(cc_socio_recomendado != cc_soc2));

alter table socio_recomendado add primary key(cc_soc2,cc_socio_recomendado);

这是插入值的代码,但出现错误:

insert into socio_recomendado
values(1121955490,1121555490);

1 个答案:

答案 0 :(得分:0)

参考密钥是指SOCIO表。在SOCIO_RECOMENDADO表中插入值时,如果在SOCIO表中找不到该值,则会给出您提到的ORA错误。

在将值插入SOCIO_RECOMENDADO表之前,请先将值插入SOCIO表。

相关问题