我創建與2個不同的字符集類型的表:UTF8,和latin1的。如何分配的mysql主鍵或外鍵的鍵長?
1)
CREATE TABLE `aaa` (
`id` int(11) NOT NULL DEFAULT '0',
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2)
CREATE TABLE `aaa` (
`id` int(11) NOT NULL DEFAULT '0',
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
然後我插入值成若干行。 當使用 '解釋' 來選擇兩個表,我得到了不同的key_len:
1)
mysql> explain select count(*) from aaa where name = "haha";
| id | select_type |表| |鍵入| possible_keys |鍵| key_len | ref |行s |額外|
| 1 | SIMPLE | aaa | ref |名稱|名稱| 258 | const | 2 |在哪裏使用;使用index |
1行集(0.00秒)
2)
mysql> explain select count(*) from aaa where name = "haha";
| id | select_type |表| |鍵入| possible_keys |鍵| key_len | ref |行s |額外|
| 1 | SIMPLE | aaa | ref |名稱|名稱| 768 | const | 2 |在哪裏使用;使用index |
1行集(0.01秒)
不知如何分配系統的key_len對於其使用不同的字符集定義的類似的表?
MY EYESSSSSSSSSS – Scotch