CREATE SUBSCRIPTION

A DDL command for defining a subscription

CREATE SUBSCRIPTION is a DDL command for defining a logical replication subscription.

CREATE SUBSCRIPTION was added in PostgreSQL 10.

Change history

Examples

Basic execution of CREATE SUBSCRIPTION:

subtestdb=# CREATE SUBSCRIPTION test_subscription
  CONNECTION 'host=node1 dbname=testdb user=produser'
  PUBLICATION test_publication;
NOTICE:  created replication slot "test_subscription" on publisher
CREATE SUBSCRIPTION

List available subscriptions in psql:

postgres=# \dRs
                    List of subscriptions
       Name        |  Owner   | Enabled |    Publication     
-------------------+----------+---------+--------------------
 test_subscription | postgres | t       | {test_publication}
(1 row)

Categories

DDL, Logical replication, SQL command

See also

ALTER SUBSCRIPTION, DROP SUBSCRIPTION, CREATE PUBLICATION