Logical data replication is only supported in CockroachDB self-hosted clusters.
CREATE LOGICAL REPLICATION STREAM statement starts that runs between a source and destination cluster in an active-active setup.
This page is a reference for the CREATE LOGICAL REPLICATION STREAM SQL statement, which includes information on its parameters and possible options. For a step-by-step guide to set up LDR, refer to the page.
Required privileges
CREATE LOGICAL REPLICATION STREAM creates a one-way LDR stream only. To achieve bidirectional replication, you must manually create two separate streams, one in each direction, with the required privileges set on both clusters.
LDR from cluster A to B represents a one-way stream from a source to a destination cluster. LDR from cluster B to A is the reverse stream for a bidirectional setup.
To run the CREATE LOGICAL REPLICATION STREAM statement to create an LDR stream, the following privileges are required:
Grant the privilege at the table or with the statement to a :
As of v25.2, the is deprecated and will be removed in a future release. Use
REPLICATIONSOURCE and REPLICATIONDEST for authorization at the table level.Synopsis
<?xml version=“1.0” encoding=“UTF-8”?>Parameters
Options
Bidirectional LDR
Bidirectional LDR consists of two clusters with two LDR jobs running in opposite directions between the clusters. If you’re setting up , both clusters will act as a source and a destination in the respective LDR jobs. LDR supports starting with two empty tables, or one non-empty table. LDR does not support starting with two non-empty tables. When you set up bidirectional LDR, if you’re starting with one non-empty table, start the first LDR job from empty to non-empty table. Therefore, you would runCREATE LOGICAL REPLICATION STREAM from the destination cluster where the non-empty table exists.
Examples
To start LDR, you must run theCREATE LOGICAL REPLICATION STREAM statement from the destination cluster. Use the . The following examples show statement usage with different options and use cases.
Start an LDR stream
There are some tradeoffs between enabling one table per LDR job versus multiple tables in one LDR job. Multiple tables in one LDR job can be easier to operate. For example, if you pause and resume the single job, LDR will stop and resume for all the tables. However, the most granular level observability will be at the job level. One table in one LDR job will allow for table-level observability.Single table
Multiple tables
Ignore row-level TTL deletes
If you would like to ignore deletes in a unidirectional LDR stream, set the on the table. On the source cluster, alter the table to set the table storage parameter:discard = ttl-deletes option in the statement:

