0
我試圖轉發工程我的ERD工作臺6.0中的計劃,但我得到這個錯誤。我檢查過所有列類型,它們是一樣的。我在這裏查看了類似的問題,但仍然找不到答案。這裏的錯誤日誌:MYSQL錯誤:錯誤1215:無法添加外鍵約束
xecuting SQL script in server
ERROR: Error 1215: Cannot add foreign key constraint
-- -----------------------------------------------------
-- Table `proj`.`employee`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `proj`.`employee` (
`employee_id` INT NOT NULL,
`position_id` INT NOT NULL,
PRIMARY KEY (`employee_id`),
CONSTRAINT `fk_employee_employee_history1`
FOREIGN KEY (`employee_id`)
REFERENCES `proj`.`employee_history` (`employee_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_employee_equipment_rentals1`
FOREIGN KEY (`employee_id`)
REFERENCES `proj`.`equipment_rentals` (`handling_employee_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_employee_scheduled_trips1`
FOREIGN KEY (`employee_id`)
REFERENCES `proj`.`scheduled_trips` (`leader`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_employee_scheduled_trips2`
FOREIGN KEY (`employee_id`)
REFERENCES `proj`.`scheduled_trips` (`assistant`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
SQL script execution finished: statements: 8 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
不僅您的模式必須正確,任何現有的數據也必須通過約束。如果表中有任何新約束適用的數據必須滿足約束條件。我敢打賭你有一些孤兒數據。 – 2014-02-23 18:57:10