Skip to main content
Version: 1.0.16

DROP SUBSCRIPTION

DROP SUBSCRIPTION — Remove a subscription

Synopsis

DROP SUBSCRIPTION [ IF EXISTS ] name [ CASCADE | RESTRICT ]

Description

DROP SUBSCRIPTION removes a subscription from the database cluster.

Only a superuser can drop a subscription.

If the subscription is associated with a replication slot, DROP SUBSCRIPTION cannot be executed inside a transaction block. (You can use ALTER SUBSCRIPTION to disassociate the replication slot.)

Parameters

name

The name of the subscription to remove.

CASCADE

RESTRICT

These keywords have no effect, since subscriptions have no dependencies.

Note

When dropping a subscription that is associated with a replication slot on the remote host (the normal state), DROP SUBSCRIPTION will connect to the remote host and attempt to drop the replication slot as part of its operation. This is necessary to release the resources allocated for the subscription on the remote host. If this fails because the remote host is unreachable, or because the remote replication slot cannot be dropped, or because the replication slot does not exist or never existed, the DROP SUBSCRIPTION command will fail. To continue in this case, execute ALTER SUBSCRIPTION ... SET (slot_name = NONE) to disassociate the replication slot from the subscription. After that, DROP SUBSCRIPTION will no longer attempt to perform any operations on the remote host. Note that if the remote replication slot still exists, it should be dropped manually; otherwise it will continue to retain WAL, which may eventually lead to disk space exhaustion.

If the subscription is associated with a replication slot, DROP SUBSCRIPTION cannot be executed inside a transaction block.

Examples

# Drop a subscription:

DROP SUBSCRIPTION mysub;

See Also

CREATE SUBSCRIPTION, ALTER SUBSCRIPTION