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;

香港美国云服务器首选后浪云,2H2G首月10元开通。
后浪云(www.IDC.Net)提供简单好用,价格厚道的香港/美国云服务器和独立服务器。IDC+ISP+ICP资质。ARIN和APNIC会员。成熟技术团队15年行业经验。

THE END