开发者

When to use pragmas on sqlite?

开发者 https://www.devze.com 2022-12-31 08:39 出处:网络
When the pragmas are used? When the database is created for first time开发者_如何转开发 or in each connection to database?this depends on the pragma being used. from The definitive guide to SQLite,

When the pragmas are used?

When the database is created for first time开发者_如何转开发 or in each connection to database?


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消