4 ALTER PUBLICATION — change the definition of a publication
8 ALTER PUBLICATION name ADD publication_object [, ...]
9 ALTER PUBLICATION name SET publication_object [, ...]
10 ALTER PUBLICATION name DROP publication_object [, ...]
11 ALTER PUBLICATION name SET ( publication_parameter [= value] [, ... ] )
12 ALTER PUBLICATION name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESS
14 ALTER PUBLICATION name RENAME TO new_name
16 where publication_object is one of:
18 TABLE [ ONLY ] table_name [ * ] [ ( column_name [, ... ] ) ] [ WHERE ( expre
20 TABLES IN SCHEMA { schema_name | CURRENT_SCHEMA } [, ... ]
24 The command ALTER PUBLICATION can change the attributes of a
27 The first three variants change which tables/schemas are part of the
28 publication. The SET clause will replace the list of tables/schemas in
29 the publication with the specified list; the existing tables/schemas
30 that were present in the publication will be removed. The ADD and DROP
31 clauses will add and remove one or more tables/schemas from the
32 publication. Note that adding tables/schemas to a publication that is
33 already subscribed to will require an ALTER SUBSCRIPTION ... REFRESH
34 PUBLICATION action on the subscribing side in order to become
35 effective. Note also that DROP TABLES IN SCHEMA will not drop any
36 schema tables that were specified using FOR TABLE/ ADD TABLE, and the
37 combination of DROP with a WHERE clause is not allowed.
39 The fourth variant of this command listed in the synopsis can change
40 all of the publication properties specified in CREATE PUBLICATION.
41 Properties not mentioned in the command retain their previous settings.
43 The remaining variants change the owner and the name of the
46 You must own the publication to use ALTER PUBLICATION. Adding a table
47 to a publication additionally requires owning that table. The ADD
48 TABLES IN SCHEMA and SET TABLES IN SCHEMA to a publication requires the
49 invoking user to be a superuser. To alter the owner, you must be able
50 to SET ROLE to the new owning role, and that role must have CREATE
51 privilege on the database. Also, the new owner of a FOR ALL TABLES or
52 FOR TABLES IN SCHEMA publication must be a superuser. However, a
53 superuser can change the ownership of a publication regardless of these
56 Adding/Setting any schema when the publication also publishes a table
57 with a column list, and vice versa is not supported.
62 The name of an existing publication whose definition is to be
66 Name of an existing table. If ONLY is specified before the table
67 name, only that table is affected. If ONLY is not specified, the
68 table and all its descendant tables (if any) are affected.
69 Optionally, * can be specified after the table name to
70 explicitly indicate that descendant tables are included.
72 Optionally, a column list can be specified. See CREATE
73 PUBLICATION for details. Note that a subscription having several
74 publications in which the same table has been published with
75 different column lists is not supported. See Warning: Combining
76 Column Lists from Multiple Publications for details of potential
77 problems when altering column lists.
79 If the optional WHERE clause is specified, rows for which the
80 expression evaluates to false or null will not be published.
81 Note that parentheses are required around the expression. The
82 expression is evaluated with the role used for the replication
86 Name of an existing schema.
88 SET ( publication_parameter [= value] [, ... ] )
89 This clause alters publication parameters originally set by
90 CREATE PUBLICATION. See there for more information.
94 Altering the publish_via_partition_root parameter can lead to
95 data loss or duplication at the subscriber because it changes
96 the identity and schema of the published tables. Note this
97 happens only when a partition root table is specified as the
100 This problem can be avoided by refraining from modifying
101 partition leaf tables after the ALTER PUBLICATION ... SET until
102 the ALTER SUBSCRIPTION ... REFRESH PUBLICATION is executed and
103 by only refreshing using the copy_data = off option.
106 The user name of the new owner of the publication.
109 The new name for the publication.
113 Change the publication to publish only deletes and updates:
114 ALTER PUBLICATION noinsert SET (publish = 'update, delete');
116 Add some tables to the publication:
117 ALTER PUBLICATION mypublication ADD TABLE users (user_id, firstname), department
120 Change the set of columns published for a table:
121 ALTER PUBLICATION mypublication SET TABLE users (user_id, firstname, lastname),
124 Add schemas marketing and sales to the publication sales_publication:
125 ALTER PUBLICATION sales_publication ADD TABLES IN SCHEMA marketing, sales;
127 Add tables users, departments and schema production to the publication
128 production_publication:
129 ALTER PUBLICATION production_publication ADD TABLE users, departments, TABLES IN
134 ALTER PUBLICATION is a PostgreSQL extension.
138 CREATE PUBLICATION, DROP PUBLICATION, CREATE SUBSCRIPTION, ALTER