--
-- 数据库: `wikidb`
--
-- --------------------------------------------------------
--
-- 表的结构 `job`
--
CREATE TABLE IF NOT EXISTS `job` (
`job_id` int( 9 ) unsigned NOT NULL AUTO_INCREMENT ,
`job_cmd` varchar( 255 ) NOT NULL DEFAULT '',
`job_namespace` int( 11 ) NOT NULL ,
`job_title` varchar( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`job_params` blob NOT NULL ,
PRIMARY KEY ( `job_id` ) ,
KEY `job_cmd` ( `job_cmd` , `job_namespace` , `job_title` )
) ENGINE = InnoDB DEFAULT CHARSET = utf8 AUTO_INCREMENT =1;
MySQL 返回:文档
#1071 - Specified key was too long; max key length is 1000 bytes
MySQL建立索引时,数据库计算key的长度是累加所有Index用到的字段的char长度后再按下面比例乘起来不能超过限定的key长度1000:
latin1 = 1 byte = 1 character
uft8 = 3 byte = 1 character
gbk = 2 byte = 1 character
这里的 job_cmd` varchar( 255 ) ,job_namespace` int( 11 ),job_title` varchar( 255 ) 采用 utf8
(255 + 11 +255) * 3 = 1563 > 1000,所有就会报1071错误
MySQL的varchar主键只支持不超过768个字节 或者 768/2=384个双字节 或者 768/3=256个三字节的字段
而 GBK是双字节的,UTF-8是三字节的。
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 50
Server version: 5.1.35-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 50
Server version: 5.1.35-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
阅读(3337) | 评论(0) | 转发(0) |