varchar(255)v tinyblob v tinytext
时间:2020-03-06 14:49:36 来源:igfitidea点击:
我的旁边的问题是tinyblob和tinytext之间真的有什么区别吗?
购买我真正的问题是什么原因(如果有),我会选择varchar(255)而不是tinyblob或者tinytext?
解决方案
主要的存储需求和内存处理/速度:
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 bytes if column values require 0 – 255 bytes, L + 2 bytes if values may require more than 255 bytes TINYBLOB, TINYTEXT: L + 1 bytes, where L < 28
此外,请参阅这篇文章:
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. 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.
编辑:顺便说一句,斑点存储二进制数据,文本存储ASCII,多数民众赞成在TINYBLOB和TINYTEXT之间的唯一区别。
VARCHAR(255)是SQL的标准,而不是tinyblob或者tinytext。因此,脚本和应用程序将在数据库供应商之间具有更高的可移植性。
我们不能将CHARACTER SET应用于TINYTEXT,但是可以将其应用于VARCHAR(255)