BLOB (large binary objects)
Storing files and other big byte payloads is the BLOB family's job. The documented maximums matter less than the limits you hit first: packet size, row size and TOAST.
- Family
- Binary & blobs
- Missing in
- None of the five
- Gotchas
- 5 listed
Engine by engine
From 1 GB (PostgreSQL BYTEA) to terabytes (Oracle BLOB). MySQL's four BLOB sizes go from 255 bytes to 4 GB but max_allowed_packet caps real transfers; Oracle keeps big values out of line.
| 엔진 | 타입 | 저장소 | 메모 |
|---|---|---|---|
| SQL Server |
VARBINARY(MAX)
|
up to 2 GB | The replacement for deprecated IMAGE; values over about 8 KB move off-row automatically. Files over a few MB usually belong on object storage. |
| PostgreSQL |
BYTEA
|
up to 1 GB | TOAST moves large values out of line and may compress them; there is also Large Object (lo) storage with a different API. |
| MySQL |
LONGBLOB
|
up to 4 GB | TINYBLOB 255 B, BLOB 64 KB, MEDIUMBLOB 16 MB, LONGBLOB 4 GB; max_allowed_packet caps what a single statement can move. |
| SQLite |
BLOB
|
up to 1 billion bytes | SQLITE_MAX_LENGTH defaults to 1,000,000,000 bytes (hard ceiling 2,147,483,647); sqlite3_blob_* streams into an existing value. |
| Oracle |
BLOB
|
terabytes | Stored out of line with a LOB locator in the row; maximum is about (4 GB - 1) times the database block size. |
Gotchas
Where the engines disagree. These tend to surface as bugs during a migration or a port.
- MySQL's 4 GB LONGBLOB is out of reach in practice: max_allowed_packet (64 MB by default in 8.0 and 8.4) caps what one statement can send, so bigger values need a raised limit on both server and client.
- Oracle BLOB columns hold a locator, not the bytes. empty_blob() initializes them, dbms_lob reads and writes, and the data lives in separate segments - plain string functions do not work.
- PostgreSQL's TOAST compresses and moves values out of line once a row passes about 2 KB; it is transparent, but SELECT * then fetches and decompresses every bytea, so list columns explicitly.
- SQLite's incremental blob API (sqlite3_blob_open/write) can overwrite bytes in place but never grow a value: reserve the full size with zeroblob(N) first, then stream into it.
- Every engine makes big blobs slow SELECT * down. The usual rule holds: store bytes over a few MB on disk or object storage and keep a path or URL in the row.
Common questions
What is the difference between BLOB and VARBINARY(MAX)?
In SQL Server, none: VARBINARY(MAX) is the modern form of what IMAGE used to be, and values move off-row automatically when large. MySQL keeps a separate BLOB family of four sizes.
How big can a BLOB be?
PostgreSQL BYTEA: 1 GB. SQL Server: 2 GB. MySQL LONGBLOB: 4 GB on paper, capped by max_allowed_packet. SQLite: about 1 GB by default. Oracle BLOB: effectively terabytes.
Should I store files in the database?
For small files (a few KB to a few MB) it is fine and gives you transactional consistency. For bigger ones, store bytes on object storage and keep the path plus metadata in the row.
Map a type to the other four engines
The free type converter maps a type from one engine to its closest equivalent in the others and says where storage, precision or behaviour differ. The desktop app does the same mapping while you edit.