我查看过与我相同问题的许多帖子,但我仍然无法弄清楚导致此错误发生的原因。 我检查了数据类型,它们都是一致的。我检查过某些事情是否未签名,事实并非如此。我浏览了所有列,并将它们的排序规则设置为Table default,并将每个表设置为utf8。我甚至只是完全删除了外键约束并试图再次转发工程师,但它仍然会发生。
CREATE TABLE IF NOT EXISTS `Melendez`.`Books` (
`ISBN` VARCHAR(45) NOT NULL,
`Title` VARCHAR(45) NOT NULL,
`Author` INT NOT NULL,
`Publisher` INT NOT NULL,
`YearPublished` INT NULL,
`Genre` VARCHAR(45) NOT NULL,
`Quantity` INT NULL,
`NumAvailable` INT NULL,
PRIMARY KEY (`ISBN`),
INDEX `AuthorFK_idx` (`Author` ASC),
INDEX `PublisherFK_idx` (`Publisher` ASC),
INDEX `GenreFK_idx` (`Genre` ASC),
CONSTRAINT `AuthorFK`
FOREIGN KEY (`Author`)
REFERENCES `Melendez`.`Authors` (`AuthorID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `PublisherFK`
FOREIGN KEY (`Publisher`)
REFERENCES `Melendez`.`Publishers` (`PublisherID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `GenreFK`
FOREIGN KEY (`Genre`)
REFERENCES `Melendez`.`Genres` (`Genre`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
这是抛出错误的声明。 以下是引用的3个表的create table语句:
CREATE TABLE IF NOT EXISTS `Melendez`.`Authors` (
`AuthorID` INT NOT NULL AUTO_INCREMENT,
`FirstName` VARCHAR(45) NOT NULL,
`LastName` VARCHAR(45) NOT NULL,
`MI` VARCHAR(45) NULL,
PRIMARY KEY (`AuthorID`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
CREATE TABLE IF NOT EXISTS `Melendez`.`Publishers` (
`PublisherID` INT NOT NULL AUTO_INCREMENT,
`PublisherName` VARCHAR(45) NOT NULL,
PRIMARY KEY (`PublisherID`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
CREATE TABLE IF NOT EXISTS `Melendez`.`Genres` (
`Genre` VARCHAR(45) NOT NULL,
`Section` VARCHAR(45) NOT NULL,
PRIMARY KEY (`Genre`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
还有其他我可以寻找的东西吗?我觉得我到处都是。或者也许是我看上去很明显的东西。