开发者

Actual size of TEXT field (MySQL)

Will a TEXT field use the same storage space i开发者_开发知识库n the database no matter if it is empty, got a few characters or filled to the limit?


The manual page Data Type Storage Requirements describes the storage requirements of each datatype for the MyISAM engine in more detail.

Data Type   Storage Required
CHAR(M)     M × w* bytes, 0 <= M <= 255
VARCHAR(M)  L + 1 bytes if column values require 0 – 255 bytes
            L + 2 bytes if values may require more than 255 bytes
TINYTEXT    L + 1 bytes, where L < 2^8
TEXT        L + 2 bytes, where L < 2^16

*w is the number of bytes required for the maximum-length character in the character set

So in conclusion the number of bytes of storage required to store a string in a TEXT column depends on the length of the string. This differs from CHAR(100) where the same amount of storage is required regardless of the length of the string stored.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜