Syntax
Database Metadata
database_list
Returns one row per attached database.page_count
Returns the total number of pages in the database file.page_size
Returns or sets the page size in bytes. Can only be set before any tables are created.max_page_count
Returns or sets the maximum number of pages allowed in the database file.freelist_count
Returns the number of unused (free) pages in the database file.encoding
Returns the text encoding of the database.schema_version
Returns the schema version number, incremented each time the schema changes.Write operations to
schema_version are treated as no-ops in Turso (emulates defensive mode).application_id
Returns or sets the application ID stored in the database header. Applications can use this 32-bit integer to identify their database file format.user_version
Returns or sets a 32-bit integer available for application use — commonly used to track schema migration versions.Schema Introspection
table_info(table-name)
Returns one row per column in the named table.| Column | Type | Description |
|---|---|---|
cid | INTEGER | Column index (0-based) |
name | TEXT | Column name |
type | TEXT | Declared type |
notnull | INTEGER | 1 if a NOT NULL constraint exists |
dflt_value | TEXT | Default value expression, or NULL |
pk | INTEGER | 1 if the column is part of the PRIMARY KEY |
table_xinfo(table-name)
Same astable_info but includes a hidden column for identifying hidden columns in virtual tables.
table_list
Returns one row per table and view in the database.index_list(table-name)
Returns one row per index on the named table.| Column | Type | Description |
|---|---|---|
seq | INTEGER | Index sequence number |
name | TEXT | Index name |
unique | INTEGER | 1 if UNIQUE |
origin | TEXT | c (CREATE INDEX), u (UNIQUE constraint), pk (PRIMARY KEY) |
partial | INTEGER | 1 if a partial index |
index_info(index-name)
Returns one row per column in the named index.index_xinfo(index-name)
Same asindex_info but with additional metadata columns.
function_list
Returns one row per SQL function available in the current database.pragma_list
Returns the list of all PRAGMA commands supported by Turso.Database Configuration
journal_mode
Returns or sets the journaling mode.wal mode. Rollback journal modes (DELETE, TRUNCATE, PERSIST, MEMORY) are not supported.
Turso Extension: Turso also supports an experimental MVCC journal mode for concurrent writes:With MVCC mode active, you can use
BEGIN CONCURRENT for optimistic concurrent write transactions.cache_size
Returns or sets the suggested maximum number of database pages to hold in memory. A positive value is a page count; a negative value is kilobytes.cache_spill
Enables or disables cache spilling (writing dirty pages to the WAL before the cache is full).synchronous
Controls fsync behavior for durability.OFF and FULL are supported. NORMAL and EXTRA are not.
temp_store
Controls where temporary tables and indexes are stored.busy_timeout
Sets the busy-wait timeout in milliseconds. When a resource is locked, Turso waits this many milliseconds before returningSQLITE_BUSY.
query_only
When enabled, prevents any modifications to the database.foreign_keys
Enables or disables foreign key constraint enforcement. Off by default for SQLite compatibility.legacy_file_format
Returns the legacy file format flag.ignore_check_constraints
When enabled, CHECK constraints are not enforced.Integrity Checks
integrity_check
Performs a thorough integrity check of the entire database. Returnsok if no problems are found, otherwise returns one row per error.
quick_check
Performs a faster but less thorough integrity check thanintegrity_check.
WAL Operations
wal_checkpoint
Forces a WAL checkpoint, writing pages from the WAL file back to the main database file.Calling
wal_checkpoint with a parameter (e.g. PRAGMA wal_checkpoint = FULL) is not supported.Change Data Capture
Turso Extension: Change Data Capture (CDC) is a Turso-specific feature that tracks all data changes for replication, auditing, and reactive applications.
capture_data_changes_conn
Enables or disables CDC for the current connection.unstable_capture_data_changes_conn is still accepted for backwards compatibility.
Capture Modes
| Mode | Description |
|---|---|
off | Disable CDC for this connection |
id | Capture only the primary key / rowid of changed rows |
before | Capture row state before changes (for UPDATEs and DELETEs) |
after | Capture row state after changes (for INSERTs and UPDATEs) |
full | Capture before and after states plus update details |
CDC Table Structure
Changes are written to a table namedturso_cdc by default (customizable via the table_name parameter):
| Column | Type | Description |
|---|---|---|
change_id | INTEGER | Auto-incrementing unique identifier |
change_time | INTEGER | Unix epoch timestamp |
change_type | INTEGER | 1 (INSERT), 0 (UPDATE), -1 (DELETE) |
table_name | TEXT | Name of the changed table |
id | varies | Primary key / rowid of the changed row |
before | BLOB | Row data before the change (modes: before, full) |
after | BLOB | Row data after the change (modes: after, full) |
updates | BLOB | Updated column details (mode: full) |
Example
Encryption
Turso Extension: At-rest encryption is a Turso-specific experimental feature. Enable it before use.
cipher
Sets the encryption cipher for the database.| Cipher | Key Size | Description |
|---|---|---|
aes128gcm | 16 bytes | AES-128 in Galois/Counter Mode |
aes256gcm | 32 bytes | AES-256 in Galois/Counter Mode |
aegis128l | 16 bytes | AEGIS-128L |
aegis256 | 32 bytes | AEGIS-256 (recommended) |
aegis128x2 | 16 bytes | AEGIS-128 with 2× parallelization |
aegis128x4 | 16 bytes | AEGIS-128 with 4× parallelization |
aegis256x2 | 32 bytes | AEGIS-256 with 2× parallelization |
aegis256x4 | 32 bytes | AEGIS-256 with 4× parallelization |
hexkey
Sets the encryption key as a hexadecimal string.Full Encryption Example
Custom Types
Turso Extension: Custom types are a Turso-specific feature.
list_types
Lists all available types (built-in and custom) with their metadata.PRAGMA Support Summary
The table below summarizes all SQLite PRAGMAs and their support status in Turso.| PRAGMA | Status | Notes |
|---|---|---|
analysis_limit | Not supported | |
application_id | Supported | |
auto_vacuum | Not supported | |
automatic_index | Not supported | |
busy_timeout | Supported | |
cache_size | Supported | |
cache_spill | Partial | Enable/disable only; threshold not supported |
case_sensitive_like | N/A | Deprecated in SQLite |
cell_size_check | Not supported | |
checkpoint_fullsync | Not supported | |
compile_options | Not supported | |
database_list | Supported | |
encoding | Supported | |
foreign_key_check | Not supported | |
foreign_key_list | Not supported | |
foreign_keys | Supported | |
freelist_count | Supported | |
function_list | Supported | |
ignore_check_constraints | Supported | |
incremental_vacuum | Not supported | |
index_info | Supported | |
index_list | Supported | |
index_xinfo | Supported | |
integrity_check | Supported | |
journal_mode | Supported | wal and mvcc (Turso extension) |
legacy_file_format | Supported | |
locking_mode | Not supported | |
max_page_count | Supported | |
mmap_size | Not supported | |
module_list | Not supported | |
optimize | Not supported | |
page_count | Supported | |
page_size | Supported | |
pragma_list | Supported | |
query_only | Supported | |
quick_check | Supported | |
read_uncommitted | Not supported | |
recursive_triggers | Not supported | |
schema_version | Supported | Writes are no-ops (emulates defensive mode) |
secure_delete | Not supported | |
synchronous | Partial | OFF and FULL only |
table_info | Supported | |
table_list | Supported | |
table_xinfo | Supported | |
temp_store | Supported | |
user_version | Supported | |
wal_autocheckpoint | Not supported | |
wal_checkpoint | Partial | Parameterized form not supported |
writable_schema | Not supported |
See Also
- Transactions — transaction control and
BEGIN CONCURRENT - SQLite Compatibility — full SQLite compatibility reference