What is the maximum range of varchar in MySQL?
MySQL中varchar的最大范围是多少?
I am using the latest version of MySQL and in many sites it is being told that the size is 255. But when i am trying to give a higher size like 500 or 1000, it works for me. So is there a maximum number for varchar datatype?
我正在使用MySQL的最新版本,并且在许多网站中它被告知大小为255.但是当我试图给出更大的大小如500或1000时,它对我有用。那么varchar数据类型的最大数量是多少?
3 个解决方案
#1
8
It was 255 before 5.0.3, but now:
它在5.0.3之前是255,但现在:
Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 65,535.
VARCHAR列中的值是可变长度字符串。长度可以指定为0到65,535之间的值。
The documentation of 5.0.x shows the transition:
5.0.x的文档显示了转换:
Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3 and later versions.
VARCHAR列中的值是可变长度字符串。长度可以指定为MySQL 5.0.3之前的0到255之间的值,5.0.3及更高版本中的0到65,535之间的值。
#2
6
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.
VARCHAR的有效最大长度取决于最大行大小(65,535字节,在所有列之间共享)和使用的字符集。
see http://dev.mysql.com/doc/refman/5.1/en/char.html
请参阅http://dev.mysql.com/doc/refman/5.1/en/char.html
#3
2
From the specs
从规格
Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 65,535. 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.
VARCHAR列中的值是可变长度字符串。长度可以指定为0到65,535之间的值。 VARCHAR的有效最大长度取决于最大行大小(65,535字节,在所有列之间共享)和使用的字符集。
#1
8
It was 255 before 5.0.3, but now:
它在5.0.3之前是255,但现在:
Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 65,535.
VARCHAR列中的值是可变长度字符串。长度可以指定为0到65,535之间的值。
The documentation of 5.0.x shows the transition:
5.0.x的文档显示了转换:
Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3 and later versions.
VARCHAR列中的值是可变长度字符串。长度可以指定为MySQL 5.0.3之前的0到255之间的值,5.0.3及更高版本中的0到65,535之间的值。
#2
6
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.
VARCHAR的有效最大长度取决于最大行大小(65,535字节,在所有列之间共享)和使用的字符集。
see http://dev.mysql.com/doc/refman/5.1/en/char.html
请参阅http://dev.mysql.com/doc/refman/5.1/en/char.html
#3
2
From the specs
从规格
Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 65,535. 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.
VARCHAR列中的值是可变长度字符串。长度可以指定为0到65,535之间的值。 VARCHAR的有效最大长度取决于最大行大小(65,535字节,在所有列之间共享)和使用的字符集。