2012-09-26 46 views
0

可能重复:
“Specified key was too long; max key length is 1000 bytes”发生此错误的原因#1071 - 指定的密钥太长;最大密钥长度是1000字节?

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字节“升起?

+1

Duplicate:http://stackoverflow.com/questions/1037598/specified-key-was-too-long-max-key-length-is-1000-bytes http://stackoverflow.com/questions/1814532/ 1071-specified-key-was-too-long-max-key-length-is-767-bytes/http://stackoverflow.com/questions/10642429/error-1071-specified-key-was-too-long- max-key-length-is-1000-bytes-mysql http://stackoverflow.com/questions/8923854/max-key-length-is-1000-bytes http://stackoverflow.com/questions/8746207/1071- specified-key-was-long-long-max-key-length-is-1000-bytes more ...只是使用搜索。 – Jocelyn

回答

4

您的UNIQUE索引中有三个255个字符的UTF8列。每个UTF8字符最多可以占用3个字节,因此每列最多可以占用765个字节,因此整个索引的总共2295个字节(作为错误状态)超过了1000个字节的限制。

相关问题