ALTER_SUBSCRIPTION(7pg15)
π ALTER SUBSCRIPTION(7) β NAME π
ALTER_SUBSCRIPTION β change the definition of a subscription. Welcome to the PostgreSQL 15.19 documentation glow-up, bestie β¨
β¨ SYNOPSIS β¨
ALTER SUBSCRIPTION name CONNECTION 'conninfo'
ALTER SUBSCRIPTION name SET PUBLICATION publication_name [, ...] [ WITH ( publication_option [= value] [, ... ] ) ]
ALTER SUBSCRIPTION name ADD PUBLICATION publication_name [, ...] [ WITH ( publication_option [= value] [, ... ] ) ]
ALTER SUBSCRIPTION name DROP PUBLICATION publication_name [, ...] [ WITH ( 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 SKIP ( skip_option = value )
ALTER SUBSCRIPTION name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER SUBSCRIPTION name RENAME TO new_name
π¦ DESCRIPTION π¦
Okay so ALTER SUBSCRIPTION can change most of the subscription properties that you can specify in CREATE SUBSCRIPTION (CREATE_SUBSCRIPTION(7)). Itβs giving subscription makeover, no cap π
You must own the subscription to use ALTER SUBSCRIPTION. To alter the owner, you must also be a direct or indirect member of the new owning role. The new owner has to be a superuser. (Currently, all subscription owners must be superusers, so the owner checks will be bypassed in practice. But this might change in the future.)
When refreshing a publication we remove the relations that are no longer part of the publication and we also remove the table synchronization slots if there are any. It is necessary to remove these slots so that the resources allocated for the subscription on the remote host are released. If due to network breakdown or some other error, PostgreSQL is unable to remove the slots, an error will be reported. To proceed in this situation, the user either needs to retry the operation or disassociate the slot from the subscription and drop the subscription as explained in DROP SUBSCRIPTION (DROP_SUBSCRIPTION(7)). Unstick yourself, bestie π«Ά
CommandsALTER SUBSCRIPTION ... REFRESH PUBLICATIONandALTER SUBSCRIPTION ... {SET|ADD|DROP} PUBLICATION ...with refresh option astruecannot be executed inside a transaction block. These commands also cannot be executed when the subscription hastwo_phasecommit enabled, unlesscopy_dataisfalse. See columnsubtwophasestateofpg_subscriptionto know the actual two-phase state. Do not fight the transaction rules, they will win π
π PARAMETERS π
nameβ the name of a subscription whose properties are to be altered. Main character subscription energy πCONNECTION 'conninfo'β this clause replaces the connection string originally set byCREATE SUBSCRIPTION(CREATE_SUBSCRIPTION(7)). See there for more information.SET PUBLICATION publication_name,ADD PUBLICATION publication_name,DROP PUBLICATION publication_nameβ these forms change the list of subscribed publications.SETreplaces the entire list of publications with a new list.ADDadds additional publications to the list of publications.DROPremoves the publications from the list of publications.- We allow non-existent publications to be specified in
ADDandSETvariants so that users can add those later. SeeCREATE SUBSCRIPTION(CREATE_SUBSCRIPTION(7)) for more information. - By default, this command will also act like
REFRESH PUBLICATION. publication_optionspecifies additional options for this operation. The supported options are:refresh (boolean)β whenfalse, the command will not try to refresh table information.REFRESH PUBLICATIONshould then be executed separately. The default istrue.- Additionally, the options described under
REFRESH PUBLICATIONmay be specified, to control the implicit refresh operation. <butterfly>Nested options? We love a layered look π¦</butterfly>
REFRESH PUBLICATIONβ fetch missing table information from publisher. This will start replication of tables that were added to the subscribed-to publications sinceCREATE SUBSCRIPTIONor the last invocation ofREFRESH PUBLICATION. Fresh table info, freshly served β¨refresh_optionspecifies additional options for the refresh operation. The supported options are:copy_data (boolean)β specifies whether to copy pre-existing data in the publications that are being subscribed to when the replication starts. The default istrue.- Previously subscribed tables are not copied, even if a table's row filter
WHEREclause has since been modified. Important little caveat, bestie β οΈ
ENABLEβ enables a previously disabled subscription, starting the logical replication worker at the end of the transaction. Wake up, subscription π«ΆDISABLEβ disables a running subscription, stopping the logical replication worker at the end of the transaction. Nap time, worker π΄SET ( subscription_parameter [= value] [, ... ] )β this clause alters parameters originally set byCREATE SUBSCRIPTION(CREATE_SUBSCRIPTION(7)). See there for more information. The parameters that can be altered areslot_name,synchronous_commit,binary,streaming, anddisable_on_error.SKIP ( skip_option = value )β skips applying all changes of the remote transaction. If incoming data violates any constraints, logical replication will stop until it is resolved. By using theALTER SUBSCRIPTION ... SKIPcommand, the logical replication worker skips all data modification changes within the transaction. This option has no effect on the transactions that are already prepared by enablingtwo_phaseon subscriber. After the logical replication worker successfully skips the transaction or finishes a transaction, the LSN (stored inpg_subscription.subskiplsn) is cleared. SeeSection 31.5for the details of logical replication conflicts. Using this command requires superuser privilege. Big skip energy, but make it superuser-only πskip_optionspecifies options for this operation. The supported option is:lsn (pg_lsn)β specifies the finish LSN of the remote transaction whose changes are to be skipped by the logical replication worker. The finish LSN is the LSN at which the transaction is either committed or prepared. Skipping individual subtransactions is not supported. SettingNONEresets the LSN.
new_ownerβ the user name of the new owner of the subscription.new_nameβ the new name for the subscription. Rename era β¨
πΈ EXAMPLES πΈ
Change the publication subscribed by a subscription to insert_only:
ALTER SUBSCRIPTION mysub SET PUBLICATION insert_only;
Disable (stop) the subscription:
ALTER SUBSCRIPTION mysub DISABLE;
π COMPATIBILITY π
ALTER SUBSCRIPTION is a PostgreSQL extension. Periodt π
π SEE ALSO π
CREATE SUBSCRIPTION(CREATE_SUBSCRIPTION(7))DROP SUBSCRIPTION(DROP_SUBSCRIPTION(7))CREATE PUBLICATION(CREATE_PUBLICATION(7))ALTER PUBLICATION(ALTER_PUBLICATION(7))
xoxo, PostgreSQL 15.19 Β· 2026 Β· signing off bestie πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms