我在尝试将我的sql文件上传到phpmyadmin
时收到此错误#1005 - Can't create table `mydb`.`emts` (errno: 150 "Foreign key constraint is incorrectly formed")
这是emts
表:
CREATE TABLE IF NOT EXISTS `mydb`.`EMTS` (
`idEMTS` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
`nickname` VARCHAR(45) NOT NULL,
`age` VARCHAR(45) NOT NULL,
`number` VARCHAR(45) NOT NULL,
`email` VARCHAR(45) NOT NULL,
`city` VARCHAR(255) NOT NULL,
`password` VARCHAR(45) NOT NULL,
`shifts_idshifts` VARCHAR(45) NOT NULL,
`bloodtype_id` INT NOT NULL,
`street` VARCHAR(45) NOT NULL,
`building` VARCHAR(45) NOT NULL,
PRIMARY KEY (`idEMTS`),
INDEX `fk_EMTS_shifts1_idx` (`shifts_idshifts` ASC),
INDEX `fk_EMTS_bloodtype1_idx` (`bloodtype_id` ASC),
UNIQUE INDEX `nickname_UNIQUE` (`nickname` ASC),
CONSTRAINT `fk_EMTS_shifts1`
FOREIGN KEY (`shifts_idshifts`)
REFERENCES `mydb`.`shifts` (`idshifts`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_EMTS_bloodtype1`
FOREIGN KEY (`bloodtype_id`)
REFERENCES `mydb`.`bloodtype` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
这是bloodtype
表:
CREATE TABLE IF NOT EXISTS `mydb`.`bloodtype` (
`type` INT NOT NULL,
`id` INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
这是shifts
表:
CREATE TABLE IF NOT EXISTS `mydb`.`shifts` (
`startdate` INT NOT NULL,
`enddate` VARCHAR(45) NOT NULL,
`day` VARCHAR(45) NOT NULL,
`idshifts` INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`idshifts`))
ENGINE = InnoDB;
我不知道怎么回事?