简体   繁体   English

两列上的外键引用Oracle另一表中的一个pk

[英]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? 有没有办法在引用另一个表中相同PK的两列上创建外键?

Both of these columns are related to the PK. 这两个列都与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 ORA-02256:引用列数必须与引用列匹配

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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 引用PK的外键与引用唯一键的外键 - Foreign Key referencing PK vs Foreign Key referencing a unique key 一个表中的两列是否可以具有另一表中同一列的外键? - Can two columns from one table have a foreign key to the same column in another table? 引用一个或多个列的组合外键 - composite foreign key referencing one or more columns 我创建了一个带有复合主键的表(分配给两列)并创建了另一个表,它只为一列引用外键? - i created a table with compoite primary key(assign to two columns) and craed another table refering foreign key for only one column? 将表中的两列添加为另一个表中的外键 - Add two columns from a table as a foreign key in another 按条件从一列到不同表的两列的外键 - foreign key from one column to two columns of different table by condition 如何知道外键在Oracle SQL Developer中引用到哪些列? - How to know to which columns a foreign key is referencing in Oracle SQL Developer? Newb SQL问题:是否有等效的“外键”用于引用列,还是将列名作为字符串存储在另一个表中是否合乎逻辑? - Newb SQL question: Is there a “foreign key” equivalent for referencing columns, or is it logical to store column names as strings in another table? SQL Server-引用多个列的外键在源表中不在其中 - Sql Server - Foreign key referencing multiple columns one of which isn't in the source table 如何在一个表中使用两次列,以显示另一个表中两个外键列的关联值? - How do I use a column in one table twice, to show the associated values of two foreign key columns in another table?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM