BLOB
Variable-length binary large object. BLOB columns can store binary data up to 65,535 bytes, suitable for images or other non-text files.
Last updated
Was this helpful?
Variable-length binary large object. BLOB columns can store binary data up to 65,535 bytes, suitable for images or other non-text files.
Last updated
Was this helpful?
Was this helpful?
CREATE TABLE blob_example (
description VARCHAR(20),
example BLOB
) DEFAULT CHARSET=latin1; -- One byte per char makes the examples clearerINSERT INTO blob_example VALUES
('Normal foo', 'foo'),
('Trailing spaces foo', 'foo '),
('NULLed', NULL),
('Empty', ''),
('Maximum', RPAD('', 65535, CHAR(7)));SELECT description, LENGTH(example) AS length
FROM blob_example;
+---------------------+--------+
| description | length |
+---------------------+--------+
| Normal foo | 3 |
| Trailing spaces foo | 9 |
| NULLed | NULL |
| Empty | 0 |
| Maximum | 65535 |
+---------------------+--------+TRUNCATE blob_example;
INSERT INTO blob_example VALUES
('Overflow', RPAD('', 65536, CHAR(7)));
ERROR 1406 (22001): Data too long for column 'example' at row 1