Name
lock_status — Display lock state of each database
Common Usage
PRAGMA lock_status;
Description
The lock_status
pragma lists all of the databases
in a connection and their current lock status. The result set
will contain one row for each attached database.
Column name | Column type | Meaning |
---|---|---|
database
| Text | Database name |
status
| Text | Lock status |
The following locking states may be indicated:
Value | Meaning |
---|---|
unlocked
| Database has no locks |
shared
| Database has a shared read lock |
reserved
| Database has the reserved write-enable lock |
pending
| Database has the pending write-enable lock |
exclusive
| Database has the exclusive write lock |
closed
| Database file is not open |
unknown
| Lock state is not known |
The first five states correspond to
the standard locks SQLite uses to maintain read and write
transactions. The closed
value is normally returned when a brand new database file has
been created, but it has not yet been initialized. Since the
locking is done through the filesystem, any database that does
not have an associated file will return unknown
. This includes both in-memory
databases, as well as some temporary databases.
SQLite must be compiled with the
SQLITE_DEBUG
directive
for this pragma to be included.
This is an undocumented pragma.
See Also
schema_version, journal_mode, journal_size_limit, ATTACH DATABASE [SQL Cmd, Ap C], DETACH DATABASE [SQL Cmd, Ap C]
Get Using SQLite now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.