Logical data replication is only supported in CockroachDB self-hosted clusters.
CREATE LOGICALLY REPLICATED statement starts logical data replication (LDR) on a table(s) that runs between a source and destination cluster in an active-active setup. CREATE LOGICALLY REPLICATED creates the new table on the destination cluster automatically and conducts a fast, offline initial scan. It accepts unidirectional or bidirectional on as an option to create either one of the setups automatically.
Once the offline initial scan completes, the new table will come online and is ready to serve queries. In a bidirectional setup, the second LDR stream will also initialize after the offline initial scan completes.
If the table to be replicated contains user-defined types, you must use the
CREATE LOGICAL REPLICATION STREAM statement instead. You can set up unidirectional or bidirectional LDR manually with CREATE LOGICAL REPLICATION STREAM.CREATE LOGICALLY REPLICATED SQL statement, which includes information on its parameters and options. For a step-by-step guide to set up LDR, refer to the Set Up Logical Data Replication page.
Required privileges
Users need the following privileges to create an LDR stream withCREATE LOGICALLY REPLICATED:
- Source connection string user: Needs the
REPLICATIONSOURCEprivilege on the source table(s). This is the user specified in the source connection string in unidirectional or bidirectional streams. - User starting the LDR stream on the destination: Must have
CREATEon the destination database and be the same user that is specified in the destination connection string for a bidirectional stream. The destination table will be created and the user given theREPLICATIONDESTprivilege on the new table automatically. - For reverse (bidirectional) setup: The original source user must have
REPLICATIONDESTon the tables in the original source cluster.
For example, the user
maxroach will run the following statement to start LDR on the destination cluster:
maxroachrequiresCREATEon database B, implicitly getsREPLICATIONDESTandREPLICATIONSOURCEonB.table.samroachrequiresREPLICATIONSOURCEandREPLICATIONDESTonA.table.maxroachmust be the user in theBIDIRECTIONAL ONconnection string.
GRANT statement to a user or a role:
As of v25.2, the
REPLICATION system privilege 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
Examples
CREATE LOGICALLY REPLICATED will automatically create the specified source tables on the destination cluster. For unidirectional and bidirectional, run the statement to start LDR on the destination cluster that does not contain the tables.
Unidirectional
From the destination cluster of the LDR stream, run:- Fully qualified destination table name.
- Fully qualified source table name.
- External connection for the source cluster. For instructions on creating the external connection for LDR, refer to Set Up Logical Data Replication.
unidirectionaloption.- Any other options.
Bidirectional
Both clusters will act as a source and destination in bidirectional LDR setups. To start the LDR jobs, you must run this statement from the destination cluster that does not contain the tables:- Fully qualified destination table name.
- Fully qualified source table name.
- External connection for the source cluster. For instructions on creating the external connection for LDR, refer to Set Up Logical Data Replication.
bidirectional onoption defining the external connection for the destination cluster.- Any other options.

