Skip to content

LONGBLOB

CREATE TABLE example_table (
id INT AUTO_INCREMENT,
longblob_column LONGBLOB,
PRIMARY KEY(id)
);
INSERT INTO example_table (longblob_column)
VALUES(LOAD_FILE('/path/to/your/image.jpg'));

To display the output, the SELECT statement can be used:

SELECT * FROM example_table;

This may output something similar to (since LONGBLOB data are binary, it won’t be readable):

+----+------------------+
| id | longblob_column |
+----+------------------+
| 1 | Binary data |
+----+------------------+

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.