DROP SUBSCRIPTION is a DDL command for removing a subscription.
DROP SUBSCRIPTION was added in PostgreSQL 10.
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 SUBSCRIPTIONcannot 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)
DROP SUBSCRIPTION has not been modified since it was added in PostgreSQL 10.
Basic execution of
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