我在下表中遗漏了哪些关键字?
Which keywords did I missed on the following tables?
我的问题: 我在 tables 上遇到同样的错误:Tasks,TimeSheet , TimeSheetHour.
我仍然不知道我错过了哪些关键字。
这是我在 Tasks table 中遇到的错误:(与其他 tables 相同)
我可以知道在接下来的 table 中我错过了哪些关键字吗?
-- what keywords did I missed here?
CREATE TABLE Tasks(
IdTask NUMBER(10,0) NOT NULL,
IdProject NUMBER(10,0) NOT NULL,
Task_Name VARCHAR2(100) NOT NULL,
Task_Description VARCHAR2(100),
StartDate DATE NOT NULL,
EndDate DATE NOT NULL,
CreatedAt VARCHAR2(50),
UpdatedAt VARCHAR2(50),
Enabled CHAR(10),
CONSTRAINT IdTask_PK PRIMARY KEY (IdTask),
CONSTRAINT IdProject_FK FOREIGN KEY (IdProject) REFERENCE Project_T(IdProject)
);
-- what keywords did I missed here?
CREATE TABLE TimeSheet(
IdTimeSheet NUMBER(10,0) NOT NULL,
IdUser NUMBER(10,0) NOT NULL,
IdProject NUMBER(10,0) NOT NULL,
TimeSheet_Name VARCHAR2(100) NOT NULL,
TimeSheet_Description VARCHAR2(200),
CreatedAt VARCHAR2(50),
UpdatedAt VARCHAR2(50),
Enabled CHAR(10),
CONSTRAINT IdTimeSheet_PK PRIMARY KEY (IdTimeSheet),
CONSTRAINT IdProject_FK FOREIGN KEY (IdProject) REFERENCE Project_T(IdProject),
CONSTRAINT IdUser_FK FOREIGN KEY (IdUser) REFERENCE User_T(IdUser)
);
-- what keywords did I missed here?
CREATE TABLE TimeSheetHour(
IdTimeSheetHour NUMBER(10,0) NOT NULL,
IdTimeSheet NUMBER(10,0) NOT NULL,
IdUser NUMBER(10,0) NOT NULL,
IdTimeCategory NUMBER(10,0) NOT NULL,
IdTask NUMBER(10,0) NOT NULL,
Quantity NUMBER(5,0) NOT NULL,
TimeSheetHour_Description VARCHAR2(200),
CONSTRAINT IdTimeSheetHour_PK PRIMARY KEY (IdTimeSheetHour),
CONSTRAINT IdTimeSheet_FK FOREIGN KEY (IdTimeSheet) REFERENCE (TimeSheet),
CONSTRAINT IdUser_FK FOREIGN KEY (IdUser) REFERENCE (User_T),
CONSTRAINT IdTimeCategory_FK FOREIGN KEY (IdTimeCategory) REFERENCE (TimeCategory),
CONSTRAINT IdTask_FK FOREIGN KEY (IdTask) REFERENCE Tasks(IdTask)
);
关键字是 REFERENCES
而不是 REFERENCE
。
然后你有重名约束IdProject_FK
。
然后你有外键约束,你没有指定 table 被引用。
即:
CONSTRAINT IdTimeSheet_FK FOREIGN KEY (IdTimeSheet) REFERENCE (TimeSheet)
应该是:
CONSTRAINT IdTimeSheet_FK FOREIGN KEY (IdTimeSheet) REFERENCES TimeSheet(IdTimeSheet)
或者,没有大括号和明确的列名:
CONSTRAINT IdTimeSheet_FK FOREIGN KEY (IdTimeSheet) REFERENCES TimeSheet
我的问题: 我在 tables 上遇到同样的错误:Tasks,TimeSheet , TimeSheetHour.
我仍然不知道我错过了哪些关键字。
这是我在 Tasks table 中遇到的错误:(与其他 tables 相同)
我可以知道在接下来的 table 中我错过了哪些关键字吗?
-- what keywords did I missed here?
CREATE TABLE Tasks(
IdTask NUMBER(10,0) NOT NULL,
IdProject NUMBER(10,0) NOT NULL,
Task_Name VARCHAR2(100) NOT NULL,
Task_Description VARCHAR2(100),
StartDate DATE NOT NULL,
EndDate DATE NOT NULL,
CreatedAt VARCHAR2(50),
UpdatedAt VARCHAR2(50),
Enabled CHAR(10),
CONSTRAINT IdTask_PK PRIMARY KEY (IdTask),
CONSTRAINT IdProject_FK FOREIGN KEY (IdProject) REFERENCE Project_T(IdProject)
);
-- what keywords did I missed here?
CREATE TABLE TimeSheet(
IdTimeSheet NUMBER(10,0) NOT NULL,
IdUser NUMBER(10,0) NOT NULL,
IdProject NUMBER(10,0) NOT NULL,
TimeSheet_Name VARCHAR2(100) NOT NULL,
TimeSheet_Description VARCHAR2(200),
CreatedAt VARCHAR2(50),
UpdatedAt VARCHAR2(50),
Enabled CHAR(10),
CONSTRAINT IdTimeSheet_PK PRIMARY KEY (IdTimeSheet),
CONSTRAINT IdProject_FK FOREIGN KEY (IdProject) REFERENCE Project_T(IdProject),
CONSTRAINT IdUser_FK FOREIGN KEY (IdUser) REFERENCE User_T(IdUser)
);
-- what keywords did I missed here?
CREATE TABLE TimeSheetHour(
IdTimeSheetHour NUMBER(10,0) NOT NULL,
IdTimeSheet NUMBER(10,0) NOT NULL,
IdUser NUMBER(10,0) NOT NULL,
IdTimeCategory NUMBER(10,0) NOT NULL,
IdTask NUMBER(10,0) NOT NULL,
Quantity NUMBER(5,0) NOT NULL,
TimeSheetHour_Description VARCHAR2(200),
CONSTRAINT IdTimeSheetHour_PK PRIMARY KEY (IdTimeSheetHour),
CONSTRAINT IdTimeSheet_FK FOREIGN KEY (IdTimeSheet) REFERENCE (TimeSheet),
CONSTRAINT IdUser_FK FOREIGN KEY (IdUser) REFERENCE (User_T),
CONSTRAINT IdTimeCategory_FK FOREIGN KEY (IdTimeCategory) REFERENCE (TimeCategory),
CONSTRAINT IdTask_FK FOREIGN KEY (IdTask) REFERENCE Tasks(IdTask)
);
关键字是 REFERENCES
而不是 REFERENCE
。
然后你有重名约束IdProject_FK
。
然后你有外键约束,你没有指定 table 被引用。
即:
CONSTRAINT IdTimeSheet_FK FOREIGN KEY (IdTimeSheet) REFERENCE (TimeSheet)
应该是:
CONSTRAINT IdTimeSheet_FK FOREIGN KEY (IdTimeSheet) REFERENCES TimeSheet(IdTimeSheet)
或者,没有大括号和明确的列名:
CONSTRAINT IdTimeSheet_FK FOREIGN KEY (IdTimeSheet) REFERENCES TimeSheet