This document describes and defines the on-disk database file format used by SQLite.The complete state of an SQLite database is usually contained a single file on disk called the "main database file".
When a rollback journal or write-ahead log contains information necessary for recovering the state of the database, they are called a "hot journal" or "hot WAL file".
Hot journals and WAL files are only a factor during error recovery scenarios and so are uncommon, but they are part of the state of an SQLite database and so cannot be ignored.
This document defines the format of a rollback journal and the write-ahead log file, but the focus is on the main database file.
The main database file consists of one or more pages.
In common use, SQLite databases tend to range in size from a few kilobytes to a few gigabytes.
At any point in time, every page in the main database has a single use which is one of the following: New database files created by SQLite use format 4 by default.
The legacy_file_format pragma can be used to cause SQLite to create new database files using format 1.
The size of a page is a power of two between 56 inclusive.
All pages within the same database are the same size. The minimum size SQLite database is a single 512-byte page.
The page size for a database file is determined by the 2-byte integer located at an offset of 16 bytes from the beginning of the database file. The maximum size database would be 2147483646 pages at 65536 bytes per page or 140,737,488,224,256 bytes (about 140 terabytes).
Usually SQLite will hit the maximum file size limit of the underlying filesystem or disk hardware long before it hits its own internal size limit.