在服务器
中执行SQL脚本错误:错误1215:无法添加外键约束
SQL代码:
CREATE TABLE IF NOT EXISTS `CAREIS101`.`Lecture` (
`idLecture` INT NOT NULL AUTO_INCREMENT COMMENT '',
`Lecture_name` VARCHAR(45) NULL COMMENT '',
`Time` TIME NULL COMMENT '',
`Date` DATE NULL COMMENT '',
`Subject` VARCHAR(45) NULL COMMENT '',
`Block` VARCHAR(45) NULL COMMENT '',
`Semester` VARCHAR(45) NULL COMMENT '',
`Room` VARCHAR(45) NULL COMMENT '',
`Program_idProgram` INT NOT NULL COMMENT '',
`Program_Stud_Info_Stud_Num` INT NOT NULL COMMENT '',
`Lecturer_idLecturer` INT NOT NULL COMMENT '',
PRIMARY KEY (`idLecture`) COMMENT '',
INDEX `fk_Lecture_Program1_idx` (`Program_idProgram` ASC, `Program_Stud_Info_Stud_Num` ASC) COMMENT '',
INDEX `fk_Lecture_Lecturer1_idx` (`Lecturer_idLecturer` ASC) COMMENT '',
UNIQUE INDEX `Program_idProgram_UNIQUE` (`Program_idProgram` ASC) COMMENT '',
UNIQUE INDEX `Program_Stud_Info_Stud_Num_UNIQUE` (`Program_Stud_Info_Stud_Num` ASC) COMMENT '',
UNIQUE INDEX `Lecturer_idLecturer_UNIQUE` (`Lecturer_idLecturer` ASC) COMMENT '',
CONSTRAINT `fk_Lecture_Program1`
FOREIGN KEY (`Program_idProgram` , `Program_Stud_Info_Stud_Num`)
REFERENCES `CAREIS101`.`Program` (`idProgram` , `Stud_Info_Stud_Num`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Lecture_Lecturer1`
FOREIGN KEY (`Lecturer_idLecturer`)
REFERENCES `CAREIS101`.`Lecturer` (`idLecturer`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
SQL脚本执行完成:语句:8成功,1失败
以最终形式获取视图定义。 没什么可取的