The temp_store
pragma gets or sets the storage mode
used by temporary database files. This pragma does not affect
journal files.
SQLite supports the following storage modes:
Mode | Meaning |
---|---|
0 or
DEFAULT | Use compile-time default. Normally FILE . |
1 or
FILE | Use file-based storage |
2 or
MEMORY | Use memory-based storage |
The set mode can be either the name or the integer equivalent. The returned value will always be an integer.
Memory-based storage will make temporary databases equivalent to in-memory databases. File-based databases will initially be in-memory databases, until they outgrow the page cache. This means that many “file-based” temporary databases never actually make it into a file.
Changing the mode will cause all temporary databases (and the data they contain) to be deleted.
In some cases, this pragma can be
disabled with the SQLITE_TEMP_STORE
compile-time directive.
Possible compile-time values include:
Value | Meaning |
---|---|
0 | Always use files, ignore pragma |
1 | Allow pragma, default to files |
2 | Allow pragma, default to memory |
3 | Always use memory, ignore pragma |
The default value is 1. Temporary
storage defaults to using files, but allows the temp_store
pragma to override
that choice.