- 论坛徽章:
- 0
|
MySQL官网给出的char类型的存储如下:
M represents the declared column length in characters for nonbinary string types and bytes for binary string types. L represents the actual length in bytes of a given string value.
CHAR(M) M × w bytes, 0 <= M <= 255, where w is the number of bytes required for the maximum-length character in the character set. See Section 14.6.3.3.5, “Physical Row Structure” for information about CHAR data type storage requirements for InnoDB tables.
这里的M是什么意思?因为翻译中文后也读不懂M的意义,如果我的一个表创建如下:
CREATE TABLE `t02` (
`char_` char(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
因为utf8表是一个字符占用3个字节,所以我想这个w应该=3,那插入一条数据是10*3=30 byte吗?显然不太对,因为有这么一个表:
CREATE TABLE `t06` (
`char_` char(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
数据和t04的内容一样,都是10万行一样的数据,但他们的.ibd数据文件都是一样大。这里的问题就是弄不明白 M和w的意思,求高手说个明白。 |
|