DROP SUBSCRIPTION

An SQL command for removing a logical subscription

DROP SUBSCRIPTION is a DDL command for removing a subscription.

DROP SUBSCRIPTION was added in PostgreSQL 10.

Usage

Note that by default, DROP SUBSCRIPTION will attempt to drop the replication slot associated with the subscription on the publisher. This entails the following caveats:

  • DROP SUBSCRIPTION cannot be executed in a transaction
  • execution will fail if the replication slot cannot be dropped, e.g. because the publisher is unreachable

To dissasociate the subscription from its replication slot on the publisher, execute:

ALTER SUBSCRIPTION ... SET (slot_name = NONE)

Change history

DROP SUBSCRIPTION has not been modified since it was added in PostgreSQL 10.

Examples

Basic usage example for DROP SUBSCRIPTION:

postgres=# DROP SUBSCRIPTION test_subscription;
NOTICE:  dropped replication slot "test_subscription" on publisher
DROP SUBSCRIPTION

Attempting to drop a non-existent subscription:

postgres=# DROP SUBSCRIPTION other_subscription;
ERROR:  subscription "other_subscription2" does not exist

Categories

DDL, Logical replication, SQL command

See also

CREATE SUBSCRIPTION, ALTER SUBSCRIPTION