我正在尝试创建一个表来使用auto_increment捕获子类型变体的详细信息,但我一直收到错误说:
1075 - 表定义不正确;只能有一个自动列,必须将其定义为键
但是,我不确定如何正确捕获它,因为我希望每个TypeId的子类型的auto_increment从1开始....这是不可能的?
CREATE TABLE IF NOT EXISTS `types` (
`TypeID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`TypeFeatures` TEXT NOT NULL,
PRIMARY KEY (`TypeID`))
ENGINE = InnoDB;
insert into types
(TypeFeatures)
values
(1,'Type1'),
(2,'Type2'),
(3,'Type3')
;
CREATE TABLE IF NOT EXISTS `subtypes` (
`Type_ID` INT UNSIGNED NOT NULL,
`SubtypeID` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
`SubtypeFeatures` TEXT NOT NULL,
PRIMARY KEY(`Type_ID`,`SubtypeID`))
ENGINE = InnoDB;
insert into subtypes
(Type_ID,subtypeID,SubtypeFeatures)
values
(1,1,'Subtype1'),
(1,2,'Subtype2'),
(2,1,'Subtype1'),
(3,1,'Subtype1')
;
提前感谢任何建议! 柔韧