// SQLite error reference

SQLITE_TOOBIG: string or blob too big

A string, BLOB or SQL statement was larger than SQLite's limit, 1,000,000,000 bytes by default, or a lower limit set by the application.

Result code
SQLITE_TOOBIG
Name
18
Category
Primary result codes
Error message
string or blob too big

What it means

SQLITE_TOOBIG (18) is returned when a string or BLOB exceeds the maximum length, set at compile time with SQLITE_MAX_LENGTH (default 1,000,000,000 bytes) or lowered at run time with sqlite3_limit(db, SQLITE_LIMIT_LENGTH, ...). An oversized SQL statement gets the same error; its limit is SQLITE_MAX_SQL_LENGTH / SQLITE_LIMIT_SQL_LENGTH. A row larger than the length limit also fails.

Common causes

  • Storing a very large file or document in a single BLOB or TEXT value.
  • Building one huge SQL statement, such as a multi-row INSERT with millions of literal values.
  • An application or binding that lowered the limit with sqlite3_limit().
  • A group_concat() or string concatenation that grows past the limit.

How to fix it

  1. Store large files outside the database and keep their paths, or split the content into chunks across rows.

  2. Insert many rows with one prepared statement executed repeatedly, with bound parameters, instead of a single enormous statement.

    INSERT INTO items (id, name) VALUES (?, ?);  -- prepare once, bind and run per row
  3. Check whether your binding sets a lower length limit, and raise it if appropriate.

Related errors

More primary result codes errors

The code and message text are from the SQLite result and error codes documentation. Browse the full SQLite error list or search every database error.

// fewer errors, faster fixes

Work on SQLite in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQLite and the other databases you use.