BLOB means binary large object. BLOB columns store binary strings (raw bytes), which makes them suitable for binary content when keeping that content inside the database is appropriate.
CREATE TABLE document_store (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
file_name VARCHAR(255) NOT NULL,
file_data LONGBLOB NOT NULL,
PRIMARY KEY (id)
);
| Type | Maximum length |
|---|---|
| TINYBLOB | 255 bytes |
| BLOB | 65,535 bytes |
| MEDIUMBLOB | 16,777,215 bytes |
| LONGBLOB | 4,294,967,295 bytes |
BLOB values are compared as binary strings. The corresponding TEXT families store character strings and use character sets and collations.
SELECT * for large tables.Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.