-1

According to this answer TEXT has a maximum capacity of 65535 characters (or 64Kbytes). However I just build a test in which I stored a JSON string taken from a json file that is 305KBytes into t TEXT without problems

I am wondering if there is some property in TEXT that allows this

3
  • 1
    The default size for a default compiled version of SQLite is 1 billion bytes, 1,000,000,000. Note, bytes, not characters, so this depends on encoding. However, you need to call sqlite3_limit(...) to get the current actual limit. Feb 14, 2019 at 9:11
  • Read sqlite.org/limits.html for details, but the maximum length you can configure it to use is 2147483647 bytes.
    – Shawn
    Feb 14, 2019 at 9:38
  • Also, that question you linked appears to be for MySQL, not sqlite.
    – Shawn
    Feb 14, 2019 at 9:42

1 Answer 1

3

The limit, by default is 1 billion bytes rather than characters so the encoding has to be considered. However it can be changed.

The complete section regarding this is :-

Maximum length of a string or BLOB

The maximum number of bytes in a string or BLOB in SQLite is defined by the preprocessor macro SQLITE_MAX_LENGTH. The default value of this macro is 1 billion (1 thousand million or 1,000,000,000). You can raise or lower this value at compile-time using a command-line option like this:

  • DSQLITE_MAX_LENGTH=123456789

The current implementation will only support a string or BLOB length up to 2 to the power of 31-1 or 2147483647. And some built-in functions such as hex() might fail well before that point. In security-sensitive applications it is best not to try to increase the maximum string and blob length. In fact, you might do well to lower the maximum string and blob length to something more in the range of a few million if that is possible.

During part of SQLite's INSERT and SELECT processing, the complete content of each row in the database is encoded as a single BLOB. So the SQLITE_MAX_LENGTH parameter also determines the maximum number of bytes in a row.

The maximum string or BLOB length can be lowered at run-time using the sqlite3_limit(db,SQLITE_LIMIT_LENGTH,size) interface.

Limits In SQLite

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.