2.6. TEMP Databases
Tables created using the "CREATE TEMP TABLE" syntax are only visible to the
database connection in which the "CREATE TEMP TABLE" statement is originally evaluated. These TEMP tables, together with any associated indices, triggers, and views, are collectively stored in a separate temporary database file that is created as soon as the first "CREATE TEMP TABLE" statement is seen. This separate temporary database file also has an associated rollback journal. The temporary database file used to store TEMP tables is deleted automatically when the
database connection is closed using
sqlite3_close().
The TEMP database file is very similar to auxiliary database files added using the
ATTACH statement, though with a few special properties. The TEMP database is always automatically deleted when the
database connection is closed. The TEMP database always uses the
synchronous=OFF and
journal_mode=PERSIST PRAGMA settings. And, the TEMP database cannot be used with
DETACH nor can another process
ATTACH the TEMP database.
The temporary files associated with the TEMP database and its rollback journal are only created if the application makes use of the "CREATE TEMP TABLE" statement.