过去三天我一直在尝试创建图表。我正在使用Workbench版本8.0.15。由于某种原因,我无法清除下表。它是在好友版本上清除的,比我的版本低了一个步骤。
在服务器中执行SQL脚本 错误:错误3734:无法添加外键约束。引用表'employee'中约束'fk_Awards_Employee1'缺少列'idEmployee'
SQL代码:
-- -----------------------------------------------------
-- Table `mydb`.`Employee`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Employee` (
`EmployeeID` INT NOT NULL,
`Employee_LastName` VARCHAR(45) NOT NULL,
`Employee_FirstName` VARCHAR(45) NOT NULL,
`Status` VARCHAR(45) NOT NULL,
`Rank_Rate` VARCHAR(45) NOT NULL,
`Recall_Number` VARCHAR(45) NOT NULL,
`Recall_Address` VARCHAR(45) NOT NULL,
`Work_Email` VARCHAR(45) NOT NULL,
`Personal_Email` VARCHAR(45) NULL,
`Gender` VARCHAR(45) NOT NULL,
`Race` VARCHAR(45) NOT NULL,
`Number_of_Dependents` VARCHAR(45) NULL,
`Department_Department_Name` VARCHAR(45) NOT NULL,
`Building_Building_Name` VARCHAR(45) NOT NULL,
PRIMARY KEY (`EmployeeID`),
INDEX `fk_Employee_Department_idx` (`Department_Department_Name` ASC) VISIBLE,
INDEX `fk_Employee_Building1_idx` (`Building_Building_Name` ASC) VISIBLE,
CONSTRAINT `fk_Employee_Department`
FOREIGN KEY (`Department_Department_Name`)
REFERENCES `mydb`.`Department` (`Department_Name`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Employee_Building1`
FOREIGN KEY (`Building_Building_Name`)
REFERENCES `mydb`.`Building` (`Building_Name`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB