ALTER SUBSCRIPTION
ALTER SUBSCRIPTION — Change the Definition of a Subscription
Synopsis
ALTER SUBSCRIPTION name CONNECTION 'conninfo'
ALTER SUBSCRIPTION name SET PUBLICATION publication_name [, ...] [ WITH
( set_publication_option [= value] [, ... ] ) ]
ALTER SUBSCRIPTION name REFRESH PUBLICATION [ WITH ( refresh_option [= value]
[, ... ] ) ]
ALTER SUBSCRIPTION name ENABLE
ALTER SUBSCRIPTION name DISABLE
ALTER SUBSCRIPTION name SET ( subscription_parameter [= value] [, ... ] )
ALTER SUBSCRIPTION name OWNER TO { new_owner | CURRENT_USER | SESSION_USER }
ALTER SUBSCRIPTION name RENAME TO new_name
Description
ALTER SUBSCRIPTION can modify most of the subscription attributes that can be specified in CREATE SUBSCRIPTION.
You must own the subscription to use ALTER SUBSCRIPTION. To change the owner, you must also be a direct or indirect member of the new owner. The new owner must be a superuser. (Currently, all subscription owners must be superusers, so the owner check will be bypassed in practice, but this may change in the future.)
Parameters
name
The name of the subscription whose attributes are to be modified.
CONNECTION 'conninfo'
This clause modifies the connection property originally set by CREATE SUBSCRIPTION.
SET PUBLICATION publication_name
Changes the list of subscribed publications. See CREATE SUBSCRIPTION for more information. By default, this command will also behave like REFRESH PUBLICATION.
set_publication_option specifies additional options for this operation. The supported option is:
refresh (boolean)
When false, the command will not attempt to refresh table information. REFRESH PUBLICATION should then be executed separately. The default is true. Additionally, the refresh options described under REFRESH PUBLICATION can be specified.
REFRESH PUBLICATION
Fetches missing table information from the publisher. This will start replication of tables that were added to the subscribed-to publications since the last call to REFRESH PUBLICATION or since CREATE SUBSCRIPTION.
refresh_option specifies additional options for the refresh operation. The supported options are:
ALTER SUBSCRIPTION, copy_data (boolean)
Specifies whether existing data in the subscribed publications should be copied after replication starts. The default is true. (Previously subscribed tables will not be copied.)
ENABLE
Enables a previously disabled subscription, starting the logical replication worker at the end of the transaction.
DISABLE
Disables a running subscription, stopping the logical replication worker at the end of the transaction.
SET ( subscription_parameter [= value] [, ... ] )
This clause modifies parameters originally set by CREATE SUBSCRIPTION. The allowed options are slot_name and synchronous_commit.
new_owner
The user name of the new owner of the subscription.
new_name
The new name of the subscription.
Examples
# Change the publication of the subscription to insert_only:
ALTER SUBSCRIPTION mysub SET PUBLICATION insert_only;
# Disable (stop) the subscription:
ALTER SUBSCRIPTION mysub DISABLE;
See Also
CREATE SUBSCRIPTION, DROP SUBSCRIPTION, CREATE PUBLICATION, ALTER PUBLICATION