Documentation Index
Fetch the complete documentation index at: https://docs.turso.tech/llms.txt
Use this file to discover all available pages before exploring further.
PRAGMA Statements
PRAGMA statements are special commands used to query or modify database configuration, retrieve metadata, and control database behavior. Unlike standard SQL, PRAGMAs are specific to SQLite and Turso.Syntax
Database Metadata
database_list
Returns one row for each attached database.page_count
Returns the total number of pages in the database file.page_size
Returns or sets the page size of the database. The page size 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 pages in the database file.encoding
Returns the text encoding used by the database.schema_version
Returns the schema version number. This value is incremented each time the schema changes.application_id
Returns or sets the application ID stored in the database header. Applications can use this 32-bit integer to identify the database file format.user_version
Returns or sets the user version number. This is a 32-bit integer available for application use.Schema Introspection
table_info
Returns one row for each column in the named table.| Column | Type | Description |
|---|---|---|
| cid | INTEGER | Column index (0-based) |
| name | TEXT | Column name |
| type | TEXT | Declared type name |
| notnull | INTEGER | 1 if NOT NULL constraint exists |
| dflt_value | TEXT | Default value expression, or NULL |
| pk | INTEGER | 1 if column is part of the PRIMARY KEY |
table_xinfo
Similar totable_info but also includes hidden columns and additional metadata.
table_info plus a hidden column (0 for normal columns, non-zero for hidden columns in virtual tables).
table_list
Returns one row for each table and view in the database.index_list
Returns one row for each index on the named table.| Column | Type | Description |
|---|---|---|
| seq | INTEGER | Index sequence number |
| name | TEXT | Index name |
| unique | INTEGER | 1 if the index is UNIQUE |
| origin | TEXT | c for CREATE INDEX, u for UNIQUE constraint, pk for PRIMARY KEY |
| partial | INTEGER | 1 if the index is a partial index |
index_info
Returns one row for each column in the named index.index_xinfo
Similar toindex_info but includes additional columns.
function_list
Returns one row for each SQL function available.pragma_list
Returns the list of all supported PRAGMA commands.Database Configuration
journal_mode
Returns or sets the journal mode.Turso Extension: Turso supports an experimental MVCC journal mode for concurrent writes:When MVCC mode is active, you can use
BEGIN CONCURRENT for optimistic concurrent write transactions. See Transactions for details.cache_size
Returns or sets the suggested maximum number of database pages held in memory.cache_spill
Enables or disables cache spilling (writing dirty pages to the WAL before the cache is full).synchronous
Controls the fsync behavior for durability guarantees.OFF and FULL are supported in Turso.
temp_store
Controls where temporary tables and indexes are stored.busy_timeout
Sets the busy timeout in milliseconds. When a table is locked, Turso waits up to this many milliseconds before returning SQLITE_BUSY.query_only
When enabled, prevents any changes to the database.foreign_keys
Enables or disables foreign key constraint enforcement.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.ok 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.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 CDC for the current connection. Changes are captured to a designated table.unstable_capture_data_changes_conn is still accepted for backwards compatibility.
| Parameter | Description |
|---|---|
| mode | Capture mode: off, id, before, after, full |
| table_name | Custom table name for storing changes (default: turso_cdc) |
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/deletes) |
after | Capture row state after changes (for inserts/updates) |
full | Capture both before and after states, plus update details |
CDC Table Structure
The CDC table contains the following columns:| 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) |
CDC Examples
Encryption
Turso Extension: At-rest encryption is a Turso-specific feature. This feature is experimental and must be enabled 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 2x parallelization |
aegis128x4 | 16 bytes | AEGIS-128 with 4x parallelization |
aegis256x2 | 32 bytes | AEGIS-256 with 2x parallelization |
aegis256x4 | 32 bytes | AEGIS-256 with 4x parallelization |
hexkey
Sets the encryption key as a hexadecimal string.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.See Also
- Transactions for transaction control
- CREATE TYPE for custom type definitions
- Compatibility for the full list of supported PRAGMAs