【发布时间】:2018-02-23 16:42:26
【问题描述】:
我在向表中添加外键时遇到问题。任何建议都会很棒,谢谢:) 我得到的错误如下
DROP TABLE Table_One
/
CREATE TABLE Table_One
(
col1 number(10),
col2 varchar(200),
PRIMARY KEY(col1)
)
/
DROP TABLE Table_Two
/
CREATE TABLE Table_Two
(
col3 number(10),
col2 varchar(200),
PRIMARY KEY(col3),
CONSTRAINT fk_col2 FOREIGN KEY(col2) references Table_One(col2)
)
/
SQL> start newtest.sql
Table dropped.
Table created.
DROP TABLE Table_Two * 第 1 行出现错误:ORA-00942:表或视图不存在
CONSTRAINT fk_col2 FOREIGN KEY(col2) references Table_One(col2)
*
第 6 行出现错误:ORA-02270:没有匹配的唯一键或主键 列列表
【问题讨论】:
-
错字。它应该是 FOREIGN KEY(col3)
标签: sql oracle foreign-keys