varchar(255)v tinyblob v tinytext [英] varchar(255) v tinyblob v tinytext

查看:325
本文介绍了varchar(255)v tinyblob v tinytext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,tinyblob和amp小文字?

My side question is there really any difference between tinyblob & tinytext?

购买我真正的问题是什么原因,如果有的话,我会选择varchar(255)over tinyblob或tinytext吗?

Buy my real question is what reason, if any, would I choose varchar(255) over tinyblob or tinytext?

推荐答案

主要是存储要求和内存处理/速度:

Primarily storage requirements and memory handling/speed:


在下表中, M 表示非二进制字符串类型和二进制字符串类型的字节的声明列长度(以字符为单位)。 L 表示给定字符串值的实际长度(以字节为单位)。

In the following table, M represents the declared column length in characters for nonbinary string types and bytes for binary string types. L represents the actual length in bytes of a given string value.

VARCHAR( M ),VARBINARY( M ):

L + 1
字节,如果列值需要0 - 255
字节,

L + 2个字节,如果值可能
需要超过255个字节

VARCHAR(M), VARBINARY(M):
L + 1 bytes if column values require 0 – 255 bytes,
L + 2 bytes if values may require more than 255 bytes

TINYBLOB,TINYTEXT:

L + 1个字节,其中 L 2 8

TINYBLOB, TINYTEXT:
L + 1 bytes, where L < 28

另外,请参阅这个帖子:


对于正在使用的每个表,MySQL分配
内存4行。对于这些
行中的每一个,CHAR(X)/ VARCHAR(X)列都需要
的X个字符。

For each table in use, MySQL allocates memory for 4 rows. For each of these rows CHAR(X)/VARCHAR(X) column takes up the X characters.

文本/ BLOB另一方面是
由8字节指针+ a
1-4字节长度表示(取决于
BLOB / TEXT类型)。动态地使用BLOB / TEXT是
。这将
使用较少的内存,但在某些情况下,
可能会在长
运行中碎片您的内存。

A TEXT/BLOB on the other hand is represented by a 8 byte pointer + a 1-4 byte length (depending on the BLOB/TEXT type). The BLOB/TEXT is allocated dynamicly on use. This will use less memory, but in some cases it may fragment your memory in the long run.

编辑:除此之外,blob存储二进制数据和文本存储ASCII,这是TINYBLOB和TINYTEXT之间的唯一区别。

Edit: As an aside, blobs store binary data and text stores ASCII, thats the only difference between TINYBLOB and TINYTEXT.

这篇关于varchar(255)v tinyblob v tinytext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆