Error starting at line : 25 in command -
CREATE TABLE Note (
Note_ID NUMBER,
Engineer_ID NUMBER,
Project_ID NUMBER,
Bug_ID NUMBER,
Bug_Name varchar2(30),
CONSTRAINT Note_PK PRIMARY KEY (Note_ID),
FOREIGN KEY (Engineer_ID) REFERENCES Engineer(Engineer_ID),
FOREIGN KEY (Project_ID) REFERENCES Project(Project_ID),
FOREIGN KEY (Bug_ID) REFERENCES Bug(Bug_ID),
FOREIGN KEY (Bug_Name) REFERENCES Bug(Bug_Name)
)
Error report -
ORA-02270: no matching unique or primary key for this column-list
02270. 00000 - "no matching unique or primary key for this column-list"
*Cause: A REFERENCES clause in a CREATE/ALTER TABLE statement
gives a column-list for which there is no matching unique or primary
key constraint in the referenced table.
*Action: Find the correct column names using the ALL_CONS_COLUMNS
catalog view
似乎找不到解决此问题的方法...有人可以帮忙吗?很快需要分配作业。我事先有一些代码,但是我似乎无法找到任何问题:?
答案 0 :(得分:3)
错误消息很清楚。对于表中定义的每个外键,被引用的表列必须为unique
或primary key
。
因此,您要确保以下所有表列均符合此要求:
Engineer(Engineer_ID)
Project(Project_ID)
Bug(Bug_ID)
Bug(Bug_Name)
同样,问题出在列Bug_Name
上;我猜想此信息在功能上取决于Bug_ID
,而该信息已被外键引用:如果是这样,则只需要将其存储在Note
表中即可(您可以访问它)通过Bug_ID
外键)。