我正在尝试向我的 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
有任何想法吗?