TINYBLOB, BLOB, MEDIUMBLOB and LONGBLOB in MySQL
The BLOB data type comes in four different types, each with a varying maximum length of data it can hold: TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. Let's explore the specifics of each type.
What is a BLOB?
A binary large object (BLOB) is a data structure capable of holding a variable amount of binary data. The BLOB data type comes in four different types, each with a varying maximum length of data it can hold: TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB.
BLOB Types in MySQL
To delve into the specifics, let's explore the maximum lengths and storage requirements for each type:
-
TINYBLOB: This type can store up to 255 bytes of binary data. Each TINYBLOB value is accompanied by a one-byte length prefix that indicates the number of bytes within the value.
-
BLOB: With a maximum capacity of 65535 bytes (or 64KB) for binary data, the BLOB type utilizes a two-byte length prefix to represent the size of the value it stores.
-
MEDIUMBLOB: This type has a larger storage capacity of 16777215 bytes (or 16MB). To represent the length of the binary data, each MEDIUMBLOB value is accompanied by a three-byte length prefix.
- LONGBLOB: The LONGBLOB type reigns supreme in terms of storage, enabling a maximum length of 4294967295 bytes (or 4GB). A four-byte length prefix serves to represent the size of the stored binary data.
The BLOB data type offers a range of options for storing binary data, allowing for flexibility based on the size requirements of the information at hand.
Details
- Title: TINYBLOB, BLOB, MEDIUMBLOB and LONGBLOB in MySQL
- Published:
- Author: Andrew Young
- Categories: SQL Guides