我正在计划在线商店的数据库设计,并且客户表存在问题。我已经设置了PK,我正在测试输入一些虚拟数据。问题是,当我插入一个新行时,它不会自动增加+1,而更多的情况是ID为2.5,7。
SQL是:
CREATE TABLE IF NOT EXISTS `foundation`.`Customer`
( `CustomerID` INT NOT NULL AUTO_INCREMENT,
`CustomerFirstName` VARCHAR(20) NULL,
`CustomerLastName` VARCHAR(32) NULL,
`CustomerUsername` VARCHAR(20) NULL,
`CustomerPassword` VARCHAR(32) NULL,
`CustomerEmail` VARCHAR(100) NULL,
`CustomerEmailVerified` TINYINT(1) NULL,
`CustomerRegisteredDate` DATETIME NULL,
`CustomerActive` TINYINT(1) NULL,
`CustomerNewsletterSubscribed` TINYINT(1) NULL,
`CustomerDescription` TEXT NULL,
`CustomerType_CustomerTypeID` INT NOT NULL,
PRIMARY KEY (`CustomerID`),
UNIQUE INDEX `Username_UNIQUE` (`CustomerUsername` ASC),
INDEX `fk_Customer_CustomerType1_idx` (`CustomerType_CustomerTypeID` ASC),
CONSTRAINT `fk_Customer_CustomerType1`
FOREIGN KEY (`CustomerType_CustomerTypeID`)
REFERENCES `foundation`.`CustomerType` (`CustomerTypeID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION
)
ENGINE = InnoDB;
答案 0 :(得分:0)
检查以下系统变量,auto_increment_increment它应该是1.如果不是,则它将按其中的值递增。
显示类似'%auto_increment%'
的变量同时检查您是否在插入查询中手动递增。