gpt4 book ai didi

mysql - MySQL VARCHAR 的最大大小是多少?

转载 作者:IT老高 更新时间:2023-10-28 12:48:04 26 4
gpt4 key购买 nike

我想知道 MySQL VARCHAR 类型的最大大小是多少。

我读到最大大小受限于大约 65k 的行大小。我尝试将字段设置为 varchar(20000) 但它说这太大了。

我可以将它设置为 varchar(10000)。我可以设置的确切最大值是多少?

最佳答案

请记住,MySQL 有最大行大小限制

The internal representation of a MySQL table has a maximum row size limit of 65,535 bytes, not counting BLOB and TEXT types. BLOB and TEXT columns only contribute 9 to 12 bytes toward the row size limit because their contents are stored separately from the rest of the row. Read more about Limits on Table Column Count and Row Size.

单个列可以占用的最大大小,在 MySQL 5.0.3 前后不同

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. The effective maximum length of a VARCHAR in MySQL 5.0.3 and later is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used.

但是,请注意,如果您使用 utf8 或 utf8mb4 等多字节字符集,则限制会更低。

使用 TEXT 类型来克服行大小限制。

The four TEXT types are TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT. These correspond to the four BLOB types and have the same maximum lengths and storage requirements.

有关 BLOB 和 TEXT 类型的更多详细信息

更多

Data Type Storage Requirements 上查看更多详细信息它处理所有数据类型的存储要求。

关于mysql - MySQL VARCHAR 的最大大小是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13506832/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com