ALTER_SUBSCRIPTION(7pg14)
π ALTER_SUBSCRIPTION (7pg14) β the glow-up page
okay bestie, listen. this is the ALTER_SUBSCRIPTION page from the PostgreSQL 14.24 Documentation, and it's literally the "change the definition of a subscription" era. think of it as the subscription's makeover episode π
β¨ SYNOPSIS β¨
like, the whole menu of looks you can give your subscription:
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 OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER SUBSCRIPTION name RENAME TO new_name
no cap, that's the full fit list π
π¦ DESCRIPTION π¦
ALTER SUBSCRIPTION can change, like, most of the subscription properties that you can specify in CREATE SUBSCRIPTION (CREATE_SUBSCRIPTION(7)). it's giving "glow-up, not rewrite" π
so here's the vibe check on permissions: you must own the subscription to use ALTER SUBSCRIPTION. and to alter the owner, you must also be a direct or indirect member of the new owning role. also 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. so don't get too comfy π)
β οΈ okay this part matters, don't skip it: 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, anERRORwill 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 inDROP SUBSCRIPTION(DROP_SUBSCRIPTION(7)). like, it's not being dramatic, it's being correct π
and one more thing, bestie β commands ALTER SUBSCRIPTION ... REFRESH PUBLICATION and ALTER SUBSCRIPTION ... {SET|ADD|DROP} PUBLICATION ... with refresh option as true cannot be executed inside a transaction block. periodt. π«
πΈ PARAMETERS πΈ
nameβ the name of a subscription whose properties are to be altered. iconic, self-explanatory, love her.CONNECTION 'conninfo'β this clause alters the connection property originally set byCREATE SUBSCRIPTION(CREATE_SUBSCRIPTION(7)). see there for more information. it's the "new phone, who dis" of connection strings πSET PUBLICATION publication_nameADD PUBLICATION publication_nameDROP PUBLICATION publication_name
changes the list of subscribed publications. SET replaces the entire list of publications with a new list, ADD adds additional publications to the list of publications, and DROP removes the publications from the list of publications. see CREATE SUBSCRIPTION (CREATE_SUBSCRIPTION(7)) for more information. by default, this command will also act like REFRESH PUBLICATION β¨
publication_option specifies 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 PUBLICATION may be specified, to control the implicit refresh operation. yes, you can stack them, we love a layered look π
REFRESH PUBLICATIONβ fetch missing table information from publisher. this will start replication of tables that were added to the subscribed-to publications since the last invocation ofREFRESH PUBLICATIONor sinceCREATE SUBSCRIPTION. it's the "catch me up, i've been offline" moment π¦
refresh_option specifies additional options for the refresh operation. the supported options are:
copy_data(boolean) β specifies whether the existing data in the publications that are being subscribed to should be copied once the replication starts. the default istrue. (previously subscribed tables are not copied.) noted, underlined, highlighted π
ENABLEβ enables the previously disabled subscription, starting the logical replication worker at the end of transaction. she's back and she's thriving π₯DISABLEβ disables the running subscription, stopping the logical replication worker at the end of transaction. she's resting, respect it π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, andstreaming. that's the whole list, don't come for me πnew_ownerβ the user name of the new owner of the subscription. handing over the keys πnew_nameβ the new name for the subscription. rebrand 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;
literally that simple, ate and left no crumbs π
β COMPATIBILITY β
ALTER SUBSCRIPTION is a PostgreSQL extension. so like, don't go looking for her in other databases, she's built different π
π SEE ALSO π
CREATE SUBSCRIPTION(CREATE_SUBSCRIPTION(7))DROP SUBSCRIPTION(DROP_SUBSCRIPTION(7))CREATE PUBLICATION(CREATE_PUBLICATION(7))ALTER PUBLICATION(ALTER_PUBLICATION(7))
the whole friend group, fr fr π«Ά
and that's the page, bestie β brought to you by PostgreSQL 14.24, dated 2026, signing off from ALTER SUBSCRIPTION(7) with main character energy. go alter something iconic πβ¨π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-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