latin1 字符集, 65532
utf8 字符集, 21844
utf8mb4 字符集, 16128
也就是说如果设定为 utf8mb4 字符集, varchar 最多能存 16128 个字符, 不论是中文还是英文.
(65535-1-2)/1=65532
(65535-1-2)/3=21844
(65535-1-2)/4=16383 !=16128, 不满足这个"公式"
官方文档: https://dev.mysql.com/doc/refman/5.7/en/char.html
The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used.
1
jin7 OP 对了, mysql 版本是 5.7.17, 存储引擎是 innodb
|
2
jin7 OP |
3
soli 2017-09-21 10:31:47 +08:00
有用。谢谢。
|
4
iwishing 2017-09-21 17:16:27 +08:00
16383-16128=255
你试试看只有一个 colume,能有多长? |
5
iwishing 2017-09-22 12:40:08 +08:00 1
http://img.vim-cn.com/40/aefbf9e17f48daf8a6c758a1202f4de5a67342.png
which is shared among all columns, 所有列都共享这个长度 |
6
jin7 OP 我回去试试哈
|
8
jin7 OP @iwishing 65,535 bytes, which is shared among all columns
之前是我没看明白这句话. |
10
mysql 2017-10-01 10:13:34 +08:00
感谢分享
|