0

使用 MySQL 工作台正向工程我收到以下错误:

错误:错误 1215:无法添加外键约束

这是代码:

-- -----------------------------------------------------    
-- Table `Osiguranje`.`Eksperti`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `Osiguranje`.`Eksperti` (
  `Br_procjena` INT NOT NULL ,
  `Zaposeleni_JMBG` VARCHAR(20) NOT NULL ,
  INDEX `fk_Eksperti_Zaposeleni1_idx` (`Zaposeleni_JMBG` ASC) ,
  UNIQUE INDEX `Zaposeleni_JMBG_UNIQUE` (`Zaposeleni_JMBG` ASC) ,
  CONSTRAINT `fk_Eksperti_Zaposeleni1`
    FOREIGN KEY (`Zaposeleni_JMBG` )
    REFERENCES `Osiguranje`.`Zaposeleni` (`JMBG` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB

Zaposeleni_JMBG是 table 中的主键Zaposleni,类型是VARCHAR(20)(因为它也在 table 中Eksperti)。

4

0 回答 0