我有MySQL从我的数据库模型生成的以下SQL查询:
CREATE TABLE IF NOT EXISTS `Insurance Group`.`Customer info` (
`ID` INT UNSIGNED NOT NULL,
`First Name` CHAR(45) NOT NULL,
`Last Name` CHAR(45) NOT NULL,
`City` CHAR(20) NOT NULL,
`Address` VARCHAR(20) NOT NULL,
`State` CHAR(15) NOT NULL,
`Phone number` VARCHAR(15) NOT NULL,
`Credit Card` VARCHAR(20) NOT NULL,
`Exp Date` DATE NOT NULL,
PRIMARY KEY (`ID`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `Insurance Group`.`Car insurance`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Insurance Group`.`Car insurance` (
`Car Policy ID` INT UNSIGNED NOT NULL,
`ID` INT UNSIGNED NOT NULL,
`Make` CHAR(15) NOT NULL,
`Model` CHAR(15) NOT NULL,
`Year` INT NOT NULL,
`Fees` VARCHAR(20) NULL,
`Additional Driver` VARCHAR(45) BINARY NULL,
`Liability Amount` INT UNSIGNED NOT NULL,
`Collision Damage Amount` INT UNSIGNED NOT NULL,
PRIMARY KEY (`Car Policy ID`),
INDEX `fk_Car insurance_Customer info_idx` (`ID` ASC),
CONSTRAINT `CarInsurance_CustomerInfo`
FOREIGN KEY (`ID`)
REFERENCES `Insurance Group`.`Customer info` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
然后我收到错误代码:1005。无法创建表insurance group
。car insurance
(错误号:150“外键约束格式不正确”)。