Skip to content

BLOB

CREATE TABLE Images (
Id INT PRIMARY KEY,
Image BLOB NOT NULL
);
INSERT INTO Images (Id, Image) VALUES (1, LOAD_FILE('C://path//to//your//image.jpg'));

Confirming that the image has been inserted:

SELECT COUNT(*) FROM Images WHERE Id = 1;

Output:

1

In this example, a table named Images is created with two columns - Id and Image. The Image column is of BLOB datatype, which is used to store binary data, in this case an image.

LOAD_FILE function is used to read the file content and insert it in the Image BLOB field for the Id 1.

Validation is performed by counting the number of rows where Id = 1, which returns 1 showing a successful insertion.