php 长文本字段的最大长度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4294506/
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
Maximum length for longtext field
提问by Ageis
I'm developing a database driven website for a Chinese audience in PHP. The content is stored in the database as a longtext
field.
我正在用 PHP 为china观众开发一个数据库驱动的网站。内容作为longtext
字段存储在数据库中。
I was wondering how can I be sure the data to be stored isn't truncated?
我想知道如何确保要存储的数据不会被截断?
回答by Chris
It depends on the characters' sizes and some configuration options.
这取决于字符的大小和一些配置选项。
LONGTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
A TEXT column with a maximum length of 4,294,967,295 or 4GB (2^32 – 1) characters. The effective maximum length is less if the value contains multi-byte characters. The effective maximum length of LONGTEXT columns also depends on the configured maximum packet size in the client/server protocol and available memory. Each LONGTEXT value is stored using a four-byte length prefix that indicates the number of bytes in the value.
LONGTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
最大长度为 4,294,967,295 或 4GB (2^32 – 1) 个字符的 TEXT 列。如果该值包含多字节字符,则有效最大长度较小。LONGTEXT 列的有效最大长度还取决于客户端/服务器协议中配置的最大数据包大小和可用内存。每个 LONGTEXT 值都使用一个四字节长度的前缀进行存储,该前缀指示值中的字节数。
http://dev.mysql.com/doc/refman/5.0/en/string-type-overview.html
http://dev.mysql.com/doc/refman/5.0/en/string-type-overview.html