MEDIUMBLOB

MEDIUMBLOB is a BLOB (Binary Large OBject) data type in SQL. It is used to store binary data, specifically variable-length data as series of bytes, up to a size of approximately 16 megabytes. It is typically used for columns that need to hold large amounts of data, such as images or files.

Example

CREATE TABLE employees (
id INT AUTO_INCREMENT,
resume MEDIUMBLOB,
PRIMARY KEY (id)
);
INSERT INTO employees (resume)
VALUES (LOAD_FILE('/tmp/resume.pdf'));

Output

Query OK, 0 rows affected (0.04 sec)
Query OK, 1 row affected (0.01 sec)

Explanation

In the above example, a table ‘employees’ is created with a MEDIUMBLOB data type column named ‘resume’. Then, a PDF file located at ‘tmp/resume.pdf’ on the server is inserted into the ‘resume’ column of the ‘employees’ table. The MEDIUMBLOB data type is capable of storing binary data up to 16MB, making it suitable for storage of larger files such as images, audio, or PDFs within the database.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.