Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use pragmas on sqlite?

Tags:

sqlite

pragma

When the pragmas are used?

When the database is created for first time or in each connection to database?

like image 540
Sein Kraft Avatar asked May 21 '10 15:05

Sein Kraft


1 Answers

this depends on the pragma being used. from The definitive guide to SQLite, Database Configuration:

Many pragmas have both temporary and permanent forms. Temporary forms affect only the current session for the duration of its lifetime. The permanent forms are stored in the database and affect every session.

or, in the words of your question: Temporary forms are used in each connection to database, permanent forms are used when the database is created for the first time.

the pragma documentation doesn't explicitly specify if a pragma is temporary or permanent. however, it usually says something like

auto-vacuuming must be turned on before any tables are created. It is not possible to enable or disable auto-vacuum after a table has been created.

meaning auto_vacuum is a permanent pragma, or

When you change the cache size using the cache_size pragma, the change only endures for the current session.

meaning cache_size is a temporary one.

so your best bet to answer your question is to carefully read the documentation for your specific pragma. alternatively, you can study the pragma source code (search for ** PRAGMA [, case sensitive).

like image 151
ax. Avatar answered Sep 27 '22 17:09

ax.