ALTER_SUBSCRIPTION(7pg14)

πŸ“¦ version 14.24, in opensuse-leap 16.0

πŸ’… 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, 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)). 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 by CREATE SUBSCRIPTION (CREATE_SUBSCRIPTION(7)). see there for more information. it's the "new phone, who dis" of connection strings πŸ”Œ
  • SET PUBLICATION publication_name
  • ADD PUBLICATION publication_name
  • DROP 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) β€” when false, the command will not try to refresh table information. REFRESH PUBLICATION should then be executed separately. the default is true. 🫢

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 of REFRESH PUBLICATION or since CREATE 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 is true. (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 by CREATE SUBSCRIPTION (CREATE_SUBSCRIPTION(7)). see there for more information. the parameters that can be altered are slot_name, synchronous_commit, binary, and streaming. 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 πŸ‘‘

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