使用以下脚本,当我尝试创建 NetBankingTransaction 表时,它会失败并显示以下消息:
错误代码:1005。无法创建表“wah_schema.netbankingtransaction”(错误号:150)
数据库脚本:
CREATE TABLE IF NOT EXISTS `wah_schema`.`Transaction` (
`idTransaction` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`idOrder` INT UNSIGNED NOT NULL ,
`type` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`idTransaction`, `idOrder`, `type`) )
ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `wah_schema`.`NetBankingTransaction` (
`idTransaction` INT NOT NULL ,
`bankCode` VARCHAR(45) NOT NULL ,
`type` VARCHAR(45) NOT NULL DEFAULT 'NETBANKING' ,
PRIMARY KEY (`idTransaction`, `type`) ,
INDEX `fk_NetBankingTransaction_Transaction1` (`idTransaction` ASC, `type` ASC) ,
CONSTRAINT `fk_NetBankingTransaction_Transaction1`
FOREIGN KEY (`idTransaction` , `type` )
REFERENCES `wah_schema`.`Transaction` (`idTransaction` , `type` )
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
有人可以帮我理解为什么会出现这个错误吗?