Name

max_page_count — Limit the size of a database

Common Usage

PRAGMA [database.]max_page_count;
PRAGMA [database.]max_page_count = max_page;

Description

The max_page_count pragma gets or sets the maximum allowed page count for a database. This value is database specific, but is stored as part of the database connection and must be reset every time the database is opened.

If a database attempts to grow past the maximum allowed page count, an out-of-space error will be returned, similar to when a filesystem runs out of space.

Both versions of this command return the current value. If you attempt to set the value lower than the current page count, no change will be made (and the old value will be returned).

The default value is 1,073,741,823 (230 ‒ 1, or one giga-page). When used in conjunction with the default 1 KB page size, this allows databases to grow up to one terabyte. There is no way to restore the default value, other than to manually set the same value (or close and reopen the database). The max_page value is limited to a 32-bit signed value.

Get Using SQLite now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.