TEXT和BLOB区别

本文介绍了MySQL中BLOB和TEXT类型的特性及使用注意事项。BLOB类型包括TINYBLOB、BLOB、MEDIUMBLOB和LONGBLOB,用于存储不同大小的二进制数据;TEXT类型包括TINYTEXT、TEXT、MEDIUMTEXT和LONGTEXT,用于存储不同大小的文本数据。文章还强调了在查询中包含BLOB和TEXT列可能导致性能下降。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

BLOB is a binary large object that can hold a variable amount of data. The four BLOB types are TINYBLOBBLOB,MEDIUMBLOB, and LONGBLOB. These differ only in the maximum length of the values they can hold. The four TEXTtypes are TINYTEXTTEXTMEDIUMTEXT, and LONGTEXT. These correspond to the four BLOB types and have the same maximum lengths and storage requirements. See Section 11.7, “Data Type Storage Requirements”.

BLOB是二进制大object,可以存储更多的数据。BLOB类型有四种TINYBLOB,BLOB,MEDIUMBLOB和LONGBLOB,每种类型最大长度值不同。

TEXT有四种类型,TINYTEXT,TEXT,MEDIUMTEXT,LONGTEXT类型。

 

 

Instances of BLOB or TEXT columns in the result of a query that is processed using a temporary table causes the server to use a table on disk rather than in memory because the MEMORY storage engine does not support those data types (see Section 8.4.4, “How MySQL Uses Internal Temporary Tables”). Use of disk incurs a performance penalty, so include BLOB or TEXT columns in the query result only if they are really needed. For example, avoid using SELECT *, which selects all columns.

BLOB和TEXT在查询的时候会使用临时表,从而引起磁盘操作,因为内存型存储类型不支持TEXT和BLOB类型。

使用磁盘操作会引发性能下降,因此包括BLOB和TEXT列的查询,最好是需要才查询,避免使用SELECT * 操作

 

【参考资料】

1、http://dev.mysql.com/doc/refman/5.6/en/blob.html

2、http://imysql.com/2014/09/28/mysql-optimization-case-blob-stored-in-innodb-optimization.shtml

转载于:https://www.cnblogs.com/gsblog/p/4019686.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值