CREATE SUBSCRIPTION CREATE SUBSCRIPTION 7 SQL - Language Statements CREATE SUBSCRIPTION define a new subscription CREATE SUBSCRIPTION subscription_name CONNECTION 'conninfo' PUBLICATION { publication_name [, ...] } [ WITH ( option [, ... ] ) ] where option can be: | ENABLED | DISABLED | CREATE SLOT | NOCREATE SLOT | SLOT NAME = slot_name Description CREATE SUBSCRIPTION adds a new subscription for a current database. The subscription name must be distinct from the name of any existing subscription in the database. The subscription represents a replication connection to the publisher. As such this command does not only add definitions in the local catalogs but also creates a replication slot on the publisher. A logical replication worker will be started to replicate data for the new subscription at the commit of the transaction where this command is run. Additional info about subscriptions and logical replication as a whole can is available at and . Parameters subscription_name The name of the new subscription. CONNECTION 'conninfo' The connection string to the publisher. For details see . PUBLICATION publication_name Name(s) of the publications on the publisher to subscribe to. ENABLED DISABLED Specifies whether the subscription should be actively replicating or if it should be just setup but not started yet. Note that the replication slot as described above is created in either case. ENABLED is the default. CREATE SLOT NOCREATE SLOT Specifies whether the command should create the replication slot on the publisher. CREATE SLOT is the default. SLOT NAME = slot_name Name of the replication slot to use. The default behavior is to use subscription_name for slot name. Notes See for details on how to configure access control between the subscription and the publication instance. Examples Create a subscription to a remote server that replicates tables in the publications mypubclication and insert_only and starts replicating immediately on commit: CREATE SUBSCRIPTION mysub CONNECTION 'host=192.168.1.50 port=5432 user=foo dbname=foodb' PUBLICATION mypublication, insert_only; Create a subscription to a remote server that replicates tables in the insert_only publication and does not start replicating until enabled at a later time. CREATE SUBSCRIPTION mysub CONNECTION 'host=192.168.1.50 port=5432 user=foo dbname=foodb' PUBLICATION insert_only WITH (DISABLED); Compatibility CREATE SUBSCRIPTION is a PostgreSQL extension. See Also