locking_mode
Whether the connection releases file locks after each transaction (NORMAL) or keeps them (EXCLUSIVE).
- 기본값
NORMAL- Range
- NORMAL, EXCLUSIVE
- Restart needed
- 아니요
- Default checked on
- SQLite 3.5x
기능
EXCLUSIVE saves lock and unlock system calls and, in WAL mode, lets SQLite work without the shared-memory -shm file.
기본값
NORMAL. NORMAL (a stock SQLite 3.5x build).
Check the current value
PRAGMA locking_mode; SELECT * FROM pragma_locking_mode; -- table-valued form, usable in queries
Change it
PRAGMA locking_mode = EXCLUSIVE; -- this connection only
No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.
When to change it
Single-process applications that own the file for their lifetime, or WAL on file systems without shared memory support.
What can go wrong
Other connections and processes cannot access the database until this connection closes.
Questions about locking_mode
What is the default value of locking_mode in SQLite?
NORMAL. NORMAL (a stock SQLite 3.5x build).
Does changing locking_mode require a restart?
No. No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.
When should I change locking_mode?
Single-process applications that own the file for their lifetime, or WAL on file systems without shared memory support.
Back to all SQLite settings, or check the SQLite manual for every option.
Check locking_mode on your own server
SQLly runs the query above against SQLite and the other engines in this reference, from one desktop app on macOS, Windows and Linux.