2 .\" Title: ALTER PUBLICATION
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 PUBLICATION" "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_PUBLICATION \- change the definition of a publication
35 ALTER PUBLICATION \fIname\fR ADD \fIpublication_object\fR [, \&.\&.\&.]
36 ALTER PUBLICATION \fIname\fR SET \fIpublication_object\fR [, \&.\&.\&.]
37 ALTER PUBLICATION \fIname\fR DROP \fIpublication_object\fR [, \&.\&.\&.]
38 ALTER PUBLICATION \fIname\fR SET ( \fIpublication_parameter\fR [= \fIvalue\fR] [, \&.\&.\&. ] )
39 ALTER PUBLICATION \fIname\fR OWNER TO { \fInew_owner\fR | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
40 ALTER PUBLICATION \fIname\fR RENAME TO \fInew_name\fR
42 where \fIpublication_object\fR is one of:
44 TABLE [ ONLY ] \fItable_name\fR [ * ] [ ( \fIcolumn_name\fR [, \&.\&.\&. ] ) ] [ WHERE ( \fIexpression\fR ) ] [, \&.\&.\&. ]
45 TABLES IN SCHEMA { \fIschema_name\fR | CURRENT_SCHEMA } [, \&.\&.\&. ]
50 \fBALTER PUBLICATION\fR
51 can change the attributes of a publication\&.
53 The first three variants change which tables/schemas are part of the publication\&. The
55 clause will replace the list of tables/schemas in the publication with the specified list; the existing tables/schemas that were present in the publication will be removed\&. The
59 clauses will add and remove one or more tables/schemas from the publication\&. Note that adding tables/schemas to a publication that is already subscribed to will require an
60 ALTER SUBSCRIPTION \&.\&.\&. REFRESH PUBLICATION
61 action on the subscribing side in order to become effective\&. Note also that
63 will not drop any schema tables that were specified using
65 ADD TABLE, and the combination of
69 clause is not allowed\&.
71 The fourth variant of this command listed in the synopsis can change all of the publication properties specified in
72 CREATE PUBLICATION (\fBCREATE_PUBLICATION\fR(7))\&. Properties not mentioned in the command retain their previous settings\&.
74 The remaining variants change the owner and the name of the publication\&.
76 You must own the publication to use
77 \fBALTER PUBLICATION\fR\&. Adding a table to a publication additionally requires owning that table\&. The
81 to a publication requires the invoking user to be a superuser\&. To alter the owner, you must be able to
83 to the new owning role, and that role must have
85 privilege on the database\&. Also, the new owner of a
89 publication must be a superuser\&. However, a superuser can change the ownership of a publication regardless of these restrictions\&.
91 Adding/Setting any schema when the publication also publishes a table with a column list, and vice versa is not supported\&.
96 The name of an existing publication whose definition is to be altered\&.
101 Name of an existing table\&. If
103 is specified before the table name, only that table is affected\&. If
105 is not specified, the table and all its descendant tables (if any) are affected\&. Optionally,
107 can be specified after the table name to explicitly indicate that descendant tables are included\&.
109 Optionally, a column list can be specified\&. See
110 CREATE PUBLICATION (\fBCREATE_PUBLICATION\fR(7))
111 for details\&. Note that a subscription having several publications in which the same table has been published with different column lists is not supported\&. See
112 Warning: Combining Column Lists from Multiple Publications
113 for details of potential problems when altering column lists\&.
117 clause is specified, rows for which the
119 evaluates to false or null will not be published\&. Note that parentheses are required around the expression\&. The
121 is evaluated with the role used for the replication connection\&.
126 Name of an existing schema\&.
129 SET ( \fIpublication_parameter\fR [= \fIvalue\fR] [, \&.\&.\&. ] )
131 This clause alters publication parameters originally set by
132 CREATE PUBLICATION (\fBCREATE_PUBLICATION\fR(7))\&. See there for more information\&.
138 .nr an-no-space-flag 1
146 publish_via_partition_root
147 parameter can lead to data loss or duplication at the subscriber because it changes the identity and schema of the published tables\&. Note this happens only when a partition root table is specified as the replication target\&.
149 This problem can be avoided by refraining from modifying partition leaf tables after the
150 \fBALTER PUBLICATION \&.\&.\&. SET\fR
152 \fBALTER SUBSCRIPTION \&.\&.\&. REFRESH PUBLICATION\fR
153 is executed and by only refreshing using the
162 The user name of the new owner of the publication\&.
167 The new name for the publication\&.
171 Change the publication to publish only deletes and updates:
177 ALTER PUBLICATION noinsert SET (publish = \*(Aqupdate, delete\*(Aq);
183 Add some tables to the publication:
189 ALTER PUBLICATION mypublication ADD TABLE users (user_id, firstname), departments;
195 Change the set of columns published for a table:
201 ALTER PUBLICATION mypublication SET TABLE users (user_id, firstname, lastname), TABLE departments;
218 ALTER PUBLICATION sales_publication ADD TABLES IN SCHEMA marketing, sales;
230 production_publication:
236 ALTER PUBLICATION production_publication ADD TABLE users, departments, TABLES IN SCHEMA production;
243 \fBALTER PUBLICATION\fR
248 CREATE PUBLICATION (\fBCREATE_PUBLICATION\fR(7)), DROP PUBLICATION (\fBDROP_PUBLICATION\fR(7)), CREATE SUBSCRIPTION (\fBCREATE_SUBSCRIPTION\fR(7)), ALTER SUBSCRIPTION (\fBALTER_SUBSCRIPTION\fR(7))