可能重复:
“Specified key was too long; max key length is 1000 bytes”
SQL查询:
CREATE TABLE `freecomputermarket`.`Members` (
`ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`UserName` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
`Email` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
`Password` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
`BirthDate` DATE NOT NULL ,
`RegisterationDate` DATE NOT NULL ,
`ActivationCode` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
`ActivationLink` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
`IsActive` BIT( 0 ) NOT NULL ,
`Gender` CHAR( 6 ) NOT NULL ,
UNIQUE (
`UserName` ,
`ActivationCode` ,
`ActivationLink`
)
) ENGINE = MYISAM
当我执行此查询时出现错误“#1071 - 指定密钥太长;最大密钥长度是1000字节”?
答案 0 :(得分:4)
您的UNIQUE
索引中有三个255个字符的UTF8列。每个UTF8字符最多可占用3个字节,因此每列最多可占用765个字节,这使得整个索引总共有2295个字节,正如错误所述,超过了1000个字节的限制。