Oracle创建具有外键错误的表 - 无效的标识符

时间:2013-09-05 06:47:29

标签: sql database oracle foreign-keys

当我尝试添加此表时,我收到错误说无效标识符。它一直困扰着我,所以我想我会问。

CREATE TABLE HORSE 
(  
horse_id numeric PRIMARY KEY,
horse_name character(30) not null,
horse_gender character(1) not null,
horse_height decimal not null,
horse_image character(40), 
CONSTRAINT horse_breed FOREIGN KEY (breed_id) REFERENCES breed(breed_id) 
);

错误消息是;

Error at Command Line:34 Column:37
Error report:
SQL Error: ORA-00904: "BREED_ID": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:

感谢并且抱歉询问可能是一个非常愚蠢的问题。

1 个答案:

答案 0 :(得分:2)

breed_id

中需要HORSE
CREATE TABLE HORSE 
(  
horse_id numeric PRIMARY KEY,
horse_name character(30) not null,
horse_gender character(1) not null,
horse_height decimal not null,
horse_image character(40), 
breed_id numeric null
CONSTRAINT horse_breed FOREIGN KEY (breed_id) REFERENCES breed(breed_id) 
);