错误1822:无法添加外键约束。引用表“评级” SQL代码中约束“ fk_efficacy_Rating1”的缺少索引:

时间:2018-12-13 08:26:25

标签: mysql-workbench

有人可以告诉我发生了什么事吗?

在服务器中执行SQL脚本

  

错误:错误1822:无法添加外键约束。引用表“评级”中约束“ fk_efficacy_Rating1”的缺少索引   SQL代码:

-- -----------------------------------------------------
-- Table `mydb`.`efficacy`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`efficacy` (
  `duration` DATETIME NULL,
  `treatment` CHAR(45) NULL,
  `effectiveness` TINYINT NULL,
  `medication_med_name` CHAR(30) NOT NULL,
  `Rating_hospital_name` INT NOT NULL,
  `Rating_HOSPITAL_hospital_name` CHAR(25) NOT NULL,
  PRIMARY KEY (`medication_med_name`),
  INDEX `fk_efficacy_Rating1_idx` (`Rating_hospital_name` ASC, `Rating_HOSPITAL_hospital_name` ASC) VISIBLE,
  CONSTRAINT `fk_efficacy_medication`
    FOREIGN KEY (`medication_med_name`)
    REFERENCES `mydb`.`medication` (`med_name`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_efficacy_Rating1`
    FOREIGN KEY (`Rating_hospital_name` , `Rating_HOSPITAL_hospital_name`)
    REFERENCES `mydb`.`Rating` (`hospital_name` , `HOSPITAL_hospital_name`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB

SQL脚本执行完成:语句:成功13次,失败1次

以最终形式获取后视图定义。 什么都没拿

0 个答案:

没有答案