运行以下脚本时出现错误否121。是否有人有任何线索,因为脚本有什么问题?
-- -----------------------------------------------------
-- Table `Commitment`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Commitment` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`type` CHAR(1) NOT NULL DEFAULT '0' COMMENT '0:Eco Commitment|1:Community Commitment|etc',
`title` VARCHAR(180) NULL DEFAULT NULL,
`description` TEXT NULL DEFAULT NULL,
`createdById` INT(11) NOT NULL DEFAULT -1,
`createdAt` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
`updatedById` INT(11) NULL DEFAULT NULL,
`updatedAt` TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`status` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '0:Delete|1:Active|2:Deactive|3:Pending|4:Blocked|5:Suspend|etc',
PRIMARY KEY (`id`),
INDEX `idxCreatedById` (`createdById` ASC),
INDEX `idxUpdatedById` (`updatedById` ASC),
CONSTRAINT `fkProductUser1`
FOREIGN KEY (`createdById`)
REFERENCES `User` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fkProductUser2`
FOREIGN KEY (`updatedById`)
REFERENCES `User` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;
答案 0 :(得分:2)
错误代码表示这些外键名称已被使用。我要做的是,使一个关键的唯一和令人难忘,就是使用
在您的情况下,您的外键可能是
fk_commitment_createdbyid_user_id
fk_commitment_updatedbyid_user_id