2 .\" Title: ALTER SUBSCRIPTION
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "ALTER SUBSCRIPTION" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 ALTER_SUBSCRIPTION \- change the definition of a subscription
35 ALTER SUBSCRIPTION \fIname\fR CONNECTION \*(Aq\fIconninfo\fR\*(Aq
36 ALTER SUBSCRIPTION \fIname\fR SET PUBLICATION \fIpublication_name\fR [, \&.\&.\&.] [ WITH ( \fIpublication_option\fR [= \fIvalue\fR] [, \&.\&.\&. ] ) ]
37 ALTER SUBSCRIPTION \fIname\fR ADD PUBLICATION \fIpublication_name\fR [, \&.\&.\&.] [ WITH ( \fIpublication_option\fR [= \fIvalue\fR] [, \&.\&.\&. ] ) ]
38 ALTER SUBSCRIPTION \fIname\fR DROP PUBLICATION \fIpublication_name\fR [, \&.\&.\&.] [ WITH ( \fIpublication_option\fR [= \fIvalue\fR] [, \&.\&.\&. ] ) ]
39 ALTER SUBSCRIPTION \fIname\fR REFRESH PUBLICATION [ WITH ( \fIrefresh_option\fR [= \fIvalue\fR] [, \&.\&.\&. ] ) ]
40 ALTER SUBSCRIPTION \fIname\fR ENABLE
41 ALTER SUBSCRIPTION \fIname\fR DISABLE
42 ALTER SUBSCRIPTION \fIname\fR SET ( \fIsubscription_parameter\fR [= \fIvalue\fR] [, \&.\&.\&. ] )
43 ALTER SUBSCRIPTION \fIname\fR SKIP ( \fIskip_option\fR = \fIvalue\fR )
44 ALTER SUBSCRIPTION \fIname\fR OWNER TO { \fInew_owner\fR | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
45 ALTER SUBSCRIPTION \fIname\fR RENAME TO \fInew_name\fR
49 \fBALTER SUBSCRIPTION\fR
50 can change most of the subscription properties that can be specified in
51 CREATE SUBSCRIPTION (\fBCREATE_SUBSCRIPTION\fR(7))\&.
53 You must own the subscription to use
54 \fBALTER SUBSCRIPTION\fR\&. To rename a subscription or alter the owner, you must have
56 permission on the database\&. In addition, to alter the owner, you must be able to
58 to the new owning role\&. If the subscription has
59 password_required=false, only superusers can modify it\&.
61 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,
63 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
64 DROP SUBSCRIPTION (\fBDROP_SUBSCRIPTION\fR(7))\&.
67 \fBALTER SUBSCRIPTION \&.\&.\&. REFRESH PUBLICATION\fR,
68 \fBALTER SUBSCRIPTION \&.\&.\&. {SET|ADD|DROP} PUBLICATION \&.\&.\&.\fR
73 \fBALTER SUBSCRIPTION \&.\&.\&. SET (failover = true|false)\fR
75 \fBALTER SUBSCRIPTION \&.\&.\&. SET (two_phase = false)\fR
76 cannot be executed inside a transaction block\&.
79 \fBALTER SUBSCRIPTION \&.\&.\&. REFRESH PUBLICATION\fR
81 \fBALTER SUBSCRIPTION \&.\&.\&. {SET|ADD|DROP} PUBLICATION \&.\&.\&.\fR
86 also cannot be executed when the subscription has
88 commit enabled, unless
95 to know the actual two\-phase state\&.
100 The name of a subscription whose properties are to be altered\&.
103 CONNECTION \*(Aq\fIconninfo\fR\*(Aq
105 This clause replaces the connection string originally set by
106 CREATE SUBSCRIPTION (\fBCREATE_SUBSCRIPTION\fR(7))\&. See there for more information\&.
109 SET PUBLICATION \fIpublication_name\fR
111 ADD PUBLICATION \fIpublication_name\fR
113 DROP PUBLICATION \fIpublication_name\fR
115 These forms change the list of subscribed publications\&.
117 replaces the entire list of publications with a new list,
119 adds additional publications to the list of publications, and
121 removes the publications from the list of publications\&. We allow non\-existent publications to be specified in
125 variants so that users can add those later\&. See
126 CREATE SUBSCRIPTION (\fBCREATE_SUBSCRIPTION\fR(7))
127 for more information\&. By default, this command will also act like
128 REFRESH PUBLICATION\&.
130 \fIpublication_option\fR
131 specifies additional options for this operation\&. The supported options are:
135 When false, the command will not try to refresh table information\&.
137 should then be executed separately\&. The default is
141 Additionally, the options described under
143 may be specified, to control the implicit refresh operation\&.
148 Fetch missing table information from publisher\&. This will start replication of tables that were added to the subscribed\-to publications since
149 \fBCREATE SUBSCRIPTION\fR
150 or the last invocation of
151 \fBREFRESH PUBLICATION\fR\&.
154 specifies additional options for the refresh operation\&. The supported options are:
158 Specifies whether to copy pre\-existing data in the publications that are being subscribed to when the replication starts\&. The default is
161 Previously subscribed tables are not copied, even if a table\*(Aqs row filter
163 clause has since been modified\&.
169 can interact with the
176 \fBCREATE SUBSCRIPTION\fR
177 for details about copying pre\-existing data in binary format\&.
183 Enables a previously disabled subscription, starting the logical replication worker at the end of the transaction\&.
188 Disables a running subscription, stopping the logical replication worker at the end of the transaction\&.
191 SET ( \fIsubscription_parameter\fR [= \fIvalue\fR] [, \&.\&.\&. ] )
193 This clause alters parameters originally set by
194 CREATE SUBSCRIPTION (\fBCREATE_SUBSCRIPTION\fR(7))\&. See there for more information\&. The parameters that can be altered are
204 two_phase\&. Only a superuser can set
205 password_required = false\&.
212 property values of the named slot may differ from the counterpart
216 parameters specified in the subscription\&. When creating the slot, ensure the slot properties
220 match their counterpart parameters of the subscription\&. Otherwise, the slot on the publisher may behave differently from what these subscription options say: for example, the slot on the publisher could either be synced to the standbys even when the subscription\*(Aqs
222 option is disabled or could be disabled for sync even when the subscription\*(Aqs
230 parameters can only be altered when the subscription is disabled\&.
237 false, the backend process reports an error if any prepared transactions done by the logical replication worker (from when
240 true) are found\&. You can resolve prepared transactions on the publisher node, or manually roll back them on the subscriber, and then try again\&. The transactions prepared by logical replication worker corresponding to a particular subscription have the following pattern:
242 (parameters: subscription
243 \fIoid\fR, remote transaction id
244 \fIxid\fR)\&. To resolve such transactions manually, you need to roll back all the prepared transactions with corresponding subscription IDs in their names\&. Applications can check
246 to find the required prepared transactions\&. After the
248 option is changed from
251 false, the publisher will replicate the transactions again when they are committed\&.
254 SKIP ( \fIskip_option\fR = \fIvalue\fR )
256 Skips applying all changes of the remote transaction\&. If incoming data violates any constraints, logical replication will stop until it is resolved\&. By using the
257 \fBALTER SUBSCRIPTION \&.\&.\&. SKIP\fR
258 command, 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 enabling
260 on the subscriber\&. After the logical replication worker successfully skips the transaction or finishes a transaction, the LSN (stored in
261 pg_subscription\&.subskiplsn) is cleared\&. See
263 for the details of logical replication conflicts\&.
266 specifies options for this operation\&. The supported option is:
270 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\&. Setting
278 The user name of the new owner of the subscription\&.
283 The new name for the subscription\&.
286 When specifying a parameter of type
290 part can be omitted, which is equivalent to specifying
294 Change the publication subscribed by a subscription to
301 ALTER SUBSCRIPTION mysub SET PUBLICATION insert_only;
307 Disable (stop) the subscription:
313 ALTER SUBSCRIPTION mysub DISABLE;
320 \fBALTER SUBSCRIPTION\fR
325 CREATE SUBSCRIPTION (\fBCREATE_SUBSCRIPTION\fR(7)), DROP SUBSCRIPTION (\fBDROP_SUBSCRIPTION\fR(7)), CREATE PUBLICATION (\fBCREATE_PUBLICATION\fR(7)), ALTER PUBLICATION (\fBALTER_PUBLICATION\fR(7))