MySQL 媒体文本的最大长度?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5227688/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:00:58  来源:igfitidea点击:

Max length of mediumtext?

mysql

提问by Click Upvote

What's the max length/number of chars in a mediumtext mysql field?

mediumtext mysql 字段中的最大长度/字符数是多少?

回答by David says reinstate Monica

While I think this question should have been answered by a simple Google search, I can't, realistically, vote to close under any of the existing options. As such I choose to offer an answer instead, in order that, hopefully, it won't be asked again and, if it is, subsequent questions may be closed as duplicates.

虽然我认为这个问题应该通过一个简单的谷歌搜索来回答,但实际上我不能投票关闭任何现有选项。因此,我选择提供一个答案,希望不会再次被问到,如果是,后续的问题可能会被关闭为重复的问题。

The maximum length of a 'mediumtext' field, in MySQL, is:

在 MySQL 中,'mediumtext' 字段最大长度是

A string with a maximum length of 16,777,215 characters.

最大长度为 16,777,215 个字符的字符串。

Or, according to the docs:

或者,根据文档

L + 3 bytes, where L < 224

L + 3 个字节,其中 L < 2 24

回答by Gerrit Brink

You cannot make an assumption that 16,777,215 characters can be stored in a medium-text field. This depends on the character encoding, in some instances a single character can be comprised of more than one byte (wide characters or Unicode characters).

您不能假设在中等文本字段中可以存储 16,777,215 个字符。这取决于字符编码,在某些情况下,单个字符可以由多个字节(宽字符或 Unicode 字符)组成。

Checking the actual size in bytes remains the safest bet, especially if you want to develop a localized application.

检查以字节为单位的实际大小仍然是最安全的选择,特别是如果您想开发本地化应用程序。