Skip to main content
Change Data Capture (CDC) tracks all data changes (inserts, updates, deletes) made to your database tables. Changes are recorded in a local table that you can query like any other table. This is useful for building reactive applications, syncing data between systems, auditing, and more.

Enable CDC

Enable CDC per connection using a PRAGMA:
To disable:
CDC cannot be used together with MVCC. They are mutually exclusive on the same connection.

Capture Modes

CDC Table

Changes are stored in the turso_cdc table by default. You can specify a custom table name:
The CDC table has the following schema:

Querying Changes

Decoding Binary Records

The before, after, and updates columns store data in a binary format. Use the built-in helper functions to decode them:

Transactions

CDC respects transaction boundaries. Changes are only recorded when a transaction commits. If a transaction rolls back, no CDC entries are created. All rows from the same transaction share the same change_txn_id, with a single COMMIT record (change_type = 2) at the end:

Schema Changes

CDC also tracks DDL operations (CREATE TABLE, DROP TABLE, CREATE INDEX, etc.) as changes to the sqlite_schema table:

Multiple Connections

Each connection has its own independent CDC configuration. Different connections can capture to different tables:

Example