简体   繁体   中英

Foreign key on two columns referencing one pk in another table on Oracle

Is there a way to create a foreign key on two columns that reference the same PK in another table?

Both of these columns are related to the PK.

Here is what I have:

CONSTRAINT some_FK FOREIGN KEY (col1, col2) REFERENCES table(col_PK); 

But I keep getting the following error:

ORA-02256: number of referencing columns must match referenced columns

You want two different foreign keys:

CONSTRAINT old_player_fk FOREIGN KEY (old_player_id) REFERENCES player(id), 
CONSTRAINT new_player_fk FOREIGN KEY (new_player_id) REFERENCES player(id)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM