gpt4 book ai didi

sql - 简单地添加一个外键 SQL

转载 作者:行者123 更新时间:2023-12-04 00:42:44 25 4
gpt4 key购买 nike

<分区>

我正在尝试向我的 user_info 表添加外键约束,这是我的用户表 (user_id) 中的主键:

ALTER TABLE user_info
ADD CONSTRAINT fk_userID
FOREIGN KEY (user_id)
REFERENCES users(user_id);

但是,我收到了这个错误:

Error starting at line 26 in command:
ALTER TABLE user_info
ADD CONSTRAINT fk_userID
FOREIGN KEY (user_id)
REFERENCES users(user_id)
Error report:
SQL Error: ORA-02298: cannot validate (CLAYBANKS.FK_USERID) - parent keys not found
02298. 00000 - "cannot validate (%s.%s) - parent keys not found"
*Cause: an alter table validating constraint failed because the table has
child records.
*Action: Obvious

有什么想法吗?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com