LONGBLOB
LONGBLOB is a data type in SQL used for storing binary large object that can hold a variable amount of data. This data type can store up to 4GB of binary data, making it suitable for storing large amounts of binary information such as images or files. The LONGBLOB data type is typically used when the size of the BLOB data is unpredictable or can exceed the maximum allowable size of other BLOB types. As a binary string type, its values are stored as strings that can contain bytes with any value from 0 to 255.
Example
Output
To display the output, the SELECT
statement can be used:
This may output something similar to (since LONGBLOB data are binary, it won’t be readable):
Explanation
In the example, a table named example_table
is created with an id
column and a LONGBLOB
column. The id
is an integer that auto-increments, and the longblob_column
stores binary data. An image is inserted into the longblob_column
using LOAD_FILE()
. This function loads the image file from the provided path and it’s stored as binary data in the LONGBLOB column.