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

nencor picture nencor · Jul 24, 2012 · Viewed 141.4k times · Source

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?

Answer

Darcey picture Darcey · Jul 24, 2012

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