当我尝试添加此表时,我收到一条错误消息,提示标识符无效。它已经困扰我太久了,所以我想我应该问一下。
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:
感谢并抱歉提出了一个可能非常愚蠢的问题。
最佳答案
HORSE
表中需要breed_id
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)
);
关于sql - Oracle create table with foreign key 错误 - 标识符无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18629526/