说我缺少左括号,但我不知道为什么
CREATE TABLE PROJECT_STAFF
(
Prog_id NUMBER(5),
Project_id NUMBER(6),
Week_Year CHAR(5),
Hours_worked NUMBER(4,1) NOT NULL,
CONSTRAINT PROJECT_STAFF_Prog_id_pk PRIMARY KEY,
CONSTRAINT PROJECT_STAFF_Prog_id_fk REFERENCES PROG(Prog_id),
CONSTRAINT PROJECT_STAFF_Project_id_pk PRIMARY KEY,
CONSTRAINT PROJECT_STAFF_Project_id_fk REFERENCES PROJECT(Project_id),
CONSTRAINT PROJECT_STAFF_Week_Year_pk PRIMARY KEY,
CONSTRAINT PROJECT_STAFF_Hours_worked_ck CHECK (Hours_work > 0)
);
答案 0 :(得分:3)
外键引用需要引用键。所以,而不是:
CONSTRAINT PROJECT_STAFF_Prog_id_fk REFERENCES PROG(Prog_id),
你需要:
CONSTRAINT PROJECT_STAFF_Prog_id_fk FOREIGN KEY (Prog_id) REFERENCES PROG(Prog_id),
与其他外键同样如此。
注意:内联引用只能使用REFERENCES
语法。但是约束需要完整的语法。