What are the differences between the BLOB and TEXT datatypes in MySQL?

MysqlDatabaseTextBlob

Mysql Problem Overview


What is blob and what is text? What are the differences?

When do I need to use blob and when do I need text as data type?

Because for blob and text, there are mediumblob == mediumtext, smallblob == small text. Do they even have the same meaning?

And look at this MEDIUMBLOB, MEDIUMTEXT L + 3 bytes, where L < 224.

What is L?

Mysql Solutions


Solution 1 - Mysql

TEXT and CHAR will convert to/from the character set they have associated with time. BLOB and BINARY simply store bytes.

BLOB is used for storing binary data while Text is used to store large string.

BLOB values are treated as binary strings (byte strings). They have no character set, and sorting and comparison are based on the numeric values of the bytes in column values.

TEXT values are treated as nonbinary strings (character strings). They have a character set, and values are sorted and compared based on the collation of the character set.

http://dev.mysql.com/doc/refman/5.0/en/blob.html

Solution 2 - Mysql

Blob datatypes stores binary objects like images while text datatypes stores text objects like articles of webpages

Solution 3 - Mysql

TEXT and CHAR or nchar that will typically be converted to plain text so you can only store text like strings.

BLOB and BINARY which mean you can store binary data such as images simply store bytes.

Solution 4 - Mysql

A BLOB is a binary string to hold a variable amount of data. For the most part BLOB's are used to hold the actual image binary instead of the path and file info. Text is for large amounts of string characters. Normally a blog or news article would constitute to a TEXT field

L in this case is used stating the storage requirement. (Length|Size + 3) as long as it is less than 224.

Reference: http://dev.mysql.com/doc/refman/5.0/en/blob.html

Solution 5 - Mysql

According to High-performance Mysql book:

> The only difference between the BLOB and TEXT families is that BLOB > types store binary data with no collation or character set, but TEXT > types have a character set and collation.

Solution 6 - Mysql

BLOB stores binary data which are more than 2 GB. Max size for BLOB is 4 GB. Binary data means unstructured data i.e images audio files vedio files digital signature

Text is used to store large string.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionnencorView Question on Stackoverflow
Solution 1 - MysqlDarceyView Answer on Stackoverflow
Solution 2 - MysqlKennyView Answer on Stackoverflow
Solution 3 - MysqlCOLD TOLDView Answer on Stackoverflow
Solution 4 - MysqlJames WilliamsView Answer on Stackoverflow
Solution 5 - MysqlAlireza Rahmani khaliliView Answer on Stackoverflow
Solution 6 - MysqlAbhishek SahaView Answer on Stackoverflow