外键无效标识符 [英] Foreign Key invalid identifier

查看:219
本文介绍了外键无效标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向表中添加外键,但出现此错误,

I am trying to add a foreign key to my table but i am getting this error,

第3行出现错误:ORA-00904:"DEDUCID":无效的标识符

ERROR at line 3: ORA-00904: "DEDUCID": invalid identifier

ALTER TABLE pr_cust
ADD CONSTRAINT deduc_fk
FOREIGN KEY (deducid)
REFERENCES pr_deduc;

我还有另一个名为pr_deduc的表,该表具有名为deducid的列,该列是一个具有一个值作为我的主键的char.除非我遗漏了某些东西,否则我已将其拼写正确.

I have this other table named pr_deduc that has a column named deducid, that is a char with one value as my primary key. I have it spelled corrected, unless i am missing something.

推荐答案

您提到的deducid必须是pr_cust上的一列,并且您没有在其他表中引用该列.适当的语法是:

The deducid you mention has to be a column on pr_cust, and you are not referencing the column in the other table. The propper syntax is:

ALTER TABLE pr_cust
ADD CONSTRAINT deduc_fk
FOREIGN KEY (deducid)
REFERENCES pr_deduc(deducid);

这篇关于外键无效标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆