The BLOB type is a binary large object type that stores a variable amount of data.
The BLOB type includes four types: TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. These types differ in the maximum length of values they can store.
BLOB values are treated as binary strings (byte strings) with a binary character set and collation. Comparisons and sorting are based on the numeric values of the bytes in the column values.
When strict SQL mode is not enabled, if a value assigned to a BLOB column exceeds the maximum length of the column, the excess part will be truncated and an alert will be generated. When strict SQL mode is enabled, if the truncated part contains non-space characters, an error will occur (instead of an alert) and the insertion of the value will be prohibited.
TINYBLOB
The TINYBLOB type 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.
An optional length M can be specified for the BLOB type. The syntax is as follows:
BLOB[(M)]
MEDIUMBLOB
The MEDIUMBLOB type is a BLOB type with a maximum length of 16,777,215 bytes.
The syntax for MEDIUMBLOB is as follows:
MEDIUMBLOB
LONGBLOB
The LONGBLOB type is a BLOB type with a maximum length of 536,870,910 bytes. The maximum effective length of a LONGBLOB column depends on the maximum packet size configured in the client/server protocol and the available memory.
The syntax for LONGBLOB is as follows:
LONGBLOB
