When to use pragmas on sqlite?

给你一囗甜甜゛ 提交于 2019-12-09 17:27:57

问题


When the pragmas are used?

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


回答1:


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



来源:https://stackoverflow.com/questions/2883527/when-to-use-pragmas-on-sqlite

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!