]> begriffs open source - ai-pg/blob - full-docs/txt/sql-alterpublication.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / sql-alterpublication.txt
1
2 ALTER PUBLICATION
3
4    ALTER PUBLICATION — change the definition of a publication
5
6 Synopsis
7
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
13 ION_USER }
14 ALTER PUBLICATION name RENAME TO new_name
15
16 where publication_object is one of:
17
18     TABLE [ ONLY ] table_name [ * ] [ ( column_name [, ... ] ) ] [ WHERE ( expre
19 ssion ) ] [, ... ]
20     TABLES IN SCHEMA { schema_name | CURRENT_SCHEMA } [, ... ]
21
22 Description
23
24    The command ALTER PUBLICATION can change the attributes of a
25    publication.
26
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.
38
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.
42
43    The remaining variants change the owner and the name of the
44    publication.
45
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
54    restrictions.
55
56    Adding/Setting any schema when the publication also publishes a table
57    with a column list, and vice versa is not supported.
58
59 Parameters
60
61    name
62           The name of an existing publication whose definition is to be
63           altered.
64
65    table_name
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.
71
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.
78
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
83           connection.
84
85    schema_name
86           Name of an existing schema.
87
88    SET ( publication_parameter [= value] [, ... ] )
89           This clause alters publication parameters originally set by
90           CREATE PUBLICATION. See there for more information.
91
92 Caution
93
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
98           replication target.
99
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.
104
105    new_owner
106           The user name of the new owner of the publication.
107
108    new_name
109           The new name for the publication.
110
111 Examples
112
113    Change the publication to publish only deletes and updates:
114 ALTER PUBLICATION noinsert SET (publish = 'update, delete');
115
116    Add some tables to the publication:
117 ALTER PUBLICATION mypublication ADD TABLE users (user_id, firstname), department
118 s;
119
120    Change the set of columns published for a table:
121 ALTER PUBLICATION mypublication SET TABLE users (user_id, firstname, lastname),
122 TABLE departments;
123
124    Add schemas marketing and sales to the publication sales_publication:
125 ALTER PUBLICATION sales_publication ADD TABLES IN SCHEMA marketing, sales;
126
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
130  SCHEMA production;
131
132 Compatibility
133
134    ALTER PUBLICATION is a PostgreSQL extension.
135
136 See Also
137
138    CREATE PUBLICATION, DROP PUBLICATION, CREATE SUBSCRIPTION, ALTER
139    SUBSCRIPTION