我正在构建数据库并且已经成功创建了2个主键表,但是当我尝试将它们作为2个外键引入另一个表时,我遇到了
"客户端ID"无效的标识符
不确定如何解决这个问题并不是最好的。
CREATE TABLE Booking(
BookingID number(10) NOT NULL,
CONSTRAINT Client_FK FOREIGN KEY (ClientID) REFERENCES client (ClientID),
CONSTRAINT Course_FK FOREIGN KEY (CourseID) REFERENCES course (CourseID),
CONSTRAINT Booking_PK PRIMARY KEY (ClientID, CourseID)
);
答案 0 :(得分:1)
您缺少创建主键和外键的列;您需要以下内容,使用适合您的列的类型进行编辑:
CREATE TABLE Booking(
BookingID number(10) NOT NULL,
ClientId number, -- missing
CourseID number, -- missing
CONSTRAINT Client_FK FOREIGN KEY (ClientID) REFERENCES client (ClientID),
CONSTRAINT Course_FK FOREIGN KEY (CourseID) REFERENCES course (CourseID),
CONSTRAINT Booking_PK PRIMARY KEY (ClientID, CourseID)
)