TINYTEXT、TEXT、MEDIUMTEXT 和 LONGTEXT 最大存储大小
根据 MySQL 文档,有四种 TEXT 类型:
- TINYTEXT
- 文本
- 中文本
- 长文本
假设字符编码为 UTF-8,我可以在每种数据类型的列中存储的最大长度是多少?
解决方案来自 文档 (MySQL 8) :
<前>类型 |最大长度-----------+------------------------------------小文字 |255 (2 8−1) 字节正文 |65,535 (216−1) 字节 = 64 KiB中文本 |16,777,215 (224−1) 字节 = 16 MiB长文 |4,294,967,295 (232−1) 字节 = 4 GiB请注意,列中可以存储的字符数量取决于字符编码.
Per the MySQL docs, there are four TEXT types:
- TINYTEXT
- TEXT
- MEDIUMTEXT
- LONGTEXT
What is the maximum length that I can store in a column of each data type assuming the character encoding is UTF-8?
解决方案From the documentation (MySQL 8) :
Type | Maximum length -----------+------------------------------------- TINYTEXT | 255 (2 8−1) bytes TEXT | 65,535 (216−1) bytes = 64 KiB MEDIUMTEXT | 16,777,215 (224−1) bytes = 16 MiB LONGTEXT | 4,294,967,295 (232−1) bytes = 4 GiB
Note that the number of characters that can be stored in your column will depend on the character encoding.
相关文章