我在使用此代码时遇到了问题:
CREATE TABLE Department (
Department_ID INTEGER PRIMARY KEY NOT NULL,
Department_Name CHAR(15) NOT NULL,
Department_Location CHAR(13) NOT NULL,
Department_Phone_Number INTEGER NOT NULL,
CONSTRAINT fk_Employee
FOREIGN KEY (Employee_ID)
REFERENCES Employee(Employee_ID)
);
我收到ORA-00904: "EMPLOYEE_ID": invalid identifier
错误,但我已经使用以下代码创建了一个员工表:
CREATE TABLE Employee (
Employee_ID INTEGER PRIMARY KEY NOT NULL,
Employee_Name CHAR(25) NOT NULL,
Date_Of_Birth DATE NOT NULL,
Job_Title CHAR (15) NOT NULL,
Marriage_Date DATE NULL,
Spouse_Name CHAR(25) NULL
);
对我做错了什么的想法?
答案 0 :(得分:0)
你需要有Employee_id列,你也可以在你的Department表中定义外键:
CREATE TABLE Department
(Department_ID integer PRIMARY KEY NOT NULL,
Department_Name CHAR(15) NOT NULL,
Department_Location CHAR(13) NOT NULL,
Department_Phone_Number integer NOT NULL,
Employee_ID integer null,
CONSTRAINT fk_Employee
FOREIGN KEY (Employee_ID)
REFERENCES Employee(Employee_ID));
答案 1 :(得分:0)
我认为在dedepartment表中没有EMPLOYEE_ID列。首先在department表中创建一个列,然后引用employee表的外键