Searched the docs, but to no avail.
What is the maximum length for an enumeration value, i.e. the string literal?
搜索了文档,但无济于事。枚举值的最大长度是多少,即字符串文字?
2 个解决方案
#1
7
The limit isn't on the length of the literal string, but rather on the table definition.
限制不在文字字符串的长度上,而是在表定义上。
The MySQL documentation states that
MySQL文档说明了这一点
Each table has an .frm file that contains the table definition. The server uses the following expression to check some of the table information stored in the file against upper limit of 64KB.
每个表都有一个包含表定义的.frm文件。服务器使用以下表达式来检查存储在文件中的某些表信息,而不是64KB的上限。
which is then followed by an ad-hoc equation expressing the approximate size of a table definition.
然后是表示表定义的近似大小的ad-hoc等式。
For a simple test, in a table with a couple fields already, I got my enum up to 63136 characters long, and the .frm was 71775 bytes big (slightly larger than 70KB), so the limit is approximate. At that point, MySQL complained #1117 - Too many columns
, which is misleading to say the least.
对于一个简单的测试,在一个已经有几个字段的表中,我的枚举长达63136个字符,而.frm大71775字节(略大于70KB),所以限制是近似值。那时,MySQL抱怨#1117 - 列太多了,这至少可以说是误导。
Interestingly/oddly/worthwhile to note, the character set of the enum will change the maximum length. -- even if you're using normal characters which should only require 1 byte each.
有趣/奇怪/值得注意,枚举的字符集将改变最大长度。 - 即使你使用普通字符,每个字符只需要1个字节。
#2
5
An ENUM column can have a maximum of 65,535 distinct elements. (The practical limit is less than 3000.) A table can have no more than 255 unique element list definitions among its ENUM and SET columns considered as a group.
ENUM列最多可包含65,535个不同的元素。 (实际限制小于3000.)一个表在其被视为一个组的ENUM和SET列中可以包含不超过255个唯一元素列表定义。
#1
7
The limit isn't on the length of the literal string, but rather on the table definition.
限制不在文字字符串的长度上,而是在表定义上。
The MySQL documentation states that
MySQL文档说明了这一点
Each table has an .frm file that contains the table definition. The server uses the following expression to check some of the table information stored in the file against upper limit of 64KB.
每个表都有一个包含表定义的.frm文件。服务器使用以下表达式来检查存储在文件中的某些表信息,而不是64KB的上限。
which is then followed by an ad-hoc equation expressing the approximate size of a table definition.
然后是表示表定义的近似大小的ad-hoc等式。
For a simple test, in a table with a couple fields already, I got my enum up to 63136 characters long, and the .frm was 71775 bytes big (slightly larger than 70KB), so the limit is approximate. At that point, MySQL complained #1117 - Too many columns
, which is misleading to say the least.
对于一个简单的测试,在一个已经有几个字段的表中,我的枚举长达63136个字符,而.frm大71775字节(略大于70KB),所以限制是近似值。那时,MySQL抱怨#1117 - 列太多了,这至少可以说是误导。
Interestingly/oddly/worthwhile to note, the character set of the enum will change the maximum length. -- even if you're using normal characters which should only require 1 byte each.
有趣/奇怪/值得注意,枚举的字符集将改变最大长度。 - 即使你使用普通字符,每个字符只需要1个字节。
#2
5
An ENUM column can have a maximum of 65,535 distinct elements. (The practical limit is less than 3000.) A table can have no more than 255 unique element list definitions among its ENUM and SET columns considered as a group.
ENUM列最多可包含65,535个不同的元素。 (实际限制小于3000.)一个表在其被视为一个组的ENUM和SET列中可以包含不超过255个唯一元素列表定义。