0
這些表是我迄今爲止的表,錯誤是表SESSIONS,我似乎無法找到錯誤是什麼?我輸入了主鍵和外鍵錯了嗎?SQL錯誤:ORA-02270:製作表時出錯
CREATE TABLE BRANCH(
BRANCHID CHAR(2) NOT NULL,
BRANCHNAME VARCHAR2(20),
BRANCHSUBURB VARCHAR2(15),
BRANCHPOSTCODE CHAR(4),
CONSTRAINT BRANCH_PK PRIMARY KEY(BRANCHID));
CREATE TABLE SCREEN(
CHAR(2) NOT NULL,
SCREENID CHAR(2) NOT NULL,
SCREENCAPACITY NUMBER(3),
CONSTRAINT SCREEN_PK PRIMARY KEY(BRANCHID, SCREENID),
CONSTRAINT SCREEN_FK FOREIGN KEY(BRANCHID) REFERENCES BRANCH(BRANCHID));
CREATE TABLE MOVIE(
MOVIEID CHAR(2) NOT NULL,
MOVIENAME VARCHAR2(20),
MOVIEGENRE VARCHAR2(20),
MOVIECLASSIFICATION VARCHAR2(5),
CONSTRAINT MOVIE_PK PRIMARY KEY(MOVIEID));
CREATE TABLE SESSIONS(
SESSIONID CHAR(4) NOT NULL,
BRANCHID CHAR(2) NOT NULL,
SCREENID CHAR(2) NOT NULL,
MOVIEID CHAR(2) NOT NULL,
SESSIONDATE DATE,
SESSIONPRICE NUMBER(4,2),
CONSTRAINT SESSIONS_PK PRIMARY KEY(SESSIONID, BRANCHID, SCREENID, MOVIEID),
CONSTRAINT SESSIONS_FK1 FOREIGN KEY(BRANCHID) REFERENCES BRANCH(BRANCHID),
CONSTRAINT SESSIONS_FK2 FOREIGN KEY(SCREENID) REFERENCES SCREEN(SCREENID),
CONSTRAINT SESSIONS_FK3 FOREIGN KEY(MOVIEID) REFERENCES MOVIE(MOVIEID));
此外,在這種情況下,它沒有任何意義獨自擁有'branchid'對外鍵;只需要把'(screenid,branchid)'作爲複合外鍵。 – mathguy