欢迎光临
我们一直在努力

ORA-25158: Cannot specify RELY for foreign key if the associated primary key is NORELY ORACLE 报错 故障修复 远程处理

文档解释

ORA-25158: Cannot specify RELY for foreign key if the associated primary key is NORELY

Cause: RELY is specified for the foreign key contraint, when the associated primary key constraint is NORELY.

Action: Change the option of the primary key also to RELY.

ORA-25158 错误指示不能为具有NORELY主键的外键指定RELY选项。

官方解释

如果创建外键时主键属性为NORELY,则不能为外键设置RELY属性。所以要么让外键使用NORELY属性,要么让主键使用RELY属性。

常见案例

当您使用以下语句创建外键时,将会出现这个错误:

ALTER TABLE child

ADD CONSTRAINT child_fk

FOREIGN KEY (parent_id)

REFERENCES parent (id);

一般处理方法及步骤

要解决这个错误,您可以为主键添加RELY属性:

ALTER TABLE parent

MODIFY id NOT NULL RELY;

或者您可以为外键添加NORELY属性:

ALTER TABLE child

ADD CONSTRAINT child_fk

FOREIGN KEY (parent_id)

REFERENCES parent (id)

NO RELY;

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。