BLOB is a binary large object type that can store variable amounts of data.
The BLOB type includes four subtypes: TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. Each subtype supports a different maximum length for stored values.
BLOB values are treated as binary strings (byte strings), with a binary character set and collation. Comparison and sorting are based on the numerical values of the bytes in the column.
When the strict SQL mode is not enabled, if a value assigned to a BLOB column exceeds its maximum length, the excess part will be truncated and an alert will be generated. When the strict SQL mode is enabled, if non-space characters are truncated, an error (instead of an alert) will be returned and the insertion will be prohibited.
TINYBLOB
TINYBLOB is a BLOB type with a maximum length of 255 bytes.
The syntax for TINYBLOB is as follows:
TINYBLOB
BLOB
The maximum length of a BLOB column is 65,535 bytes.
You can specify an optional length M for the BLOB type. The syntax is as follows:
BLOB[(M)]
MEDIUMBLOB
MEDIUMBLOB is a BLOB type with a maximum length of 16,777,215 bytes.
The syntax for MEDIUMBLOB is as follows:
MEDIUMBLOB
LONGBLOB
LONGBLOB is a BLOB type with a maximum length of approximately 4 TB (the exact upper limit is 4 TB - 1 bytes, or 4,398,046,511,103 bytes). A single write to a LOB can be up to approximately 512 MB; data exceeding 512 MB must be appended in streaming mode using the LOB_WRITEAPPEND method.
The syntax for LONGBLOB is as follows:
LONGBLOB