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 nameColumn typeMeaning
database TextDatabase name
status TextLock status

The following locking states may be indicated:

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

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.