✏️ Explanatory Question
Level: Basic — Tests your knowledge of MySQL's large-object types for storing big data.
Both BLOB and TEXT are designed to store large amounts of data that exceed the limits of CHAR/VARCHAR. The core difference is binary vs character data.
| BLOB Type | TEXT Type | Max Size |
|---|---|---|
| TINYBLOB | TINYTEXT | 255 bytes |
| BLOB | TEXT | 65,535 bytes (~64 KB) |
| MEDIUMBLOB | MEDIUMTEXT | 16,777,215 bytes (~16 MB) |
| LONGBLOB | LONGTEXT | 4,294,967,295 bytes (~4 GB) |
| Feature | BLOB | TEXT |
|---|---|---|
| Data type | Binary | Character |
| Character set / collation | None | Yes |
| Comparison / sorting | Case-sensitive (byte-wise) | Case-insensitive (collation) |
| Best for | Images, files, media | Articles, descriptions, comments |
CREATE TABLE documents (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(200),
content TEXT, -- large readable text
profile_pic BLOB, -- binary image data
attachment LONGBLOB -- large binary file up to 4 GB
);
-- Store readable text
INSERT INTO documents (title, content)
VALUES ('Guide', 'This is a long article body...');
-- TEXT comparison is case-insensitive by default
SELECT * FROM documents WHERE content LIKE '%article%';