@@ -21,12 +21,17 @@ PostgreSQL documentation
21
21
22
22
<refsynopsisdiv>
23
23
<synopsis>
24
- ALTER PUBLICATION <replaceable class="parameter">name</replaceable> ADD TABLE [ ONLY ] <replaceable class="parameter">table_name </replaceable> [ * ] [, ...]
25
- ALTER PUBLICATION <replaceable class="parameter">name</replaceable> SET TABLE [ ONLY ] <replaceable class="parameter">table_name </replaceable> [ * ] [, ...]
26
- ALTER PUBLICATION <replaceable class="parameter">name</replaceable> DROP TABLE [ ONLY ] <replaceable class="parameter">table_name </replaceable> [ * ] [, ...]
24
+ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> ADD <replaceable class="parameter">publication_object </replaceable> [, ...]
25
+ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> SET <replaceable class="parameter">publication_object </replaceable> [, ...]
26
+ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> DROP <replaceable class="parameter">publication_object </replaceable> [, ...]
27
27
ALTER PUBLICATION <replaceable class="parameter">name</replaceable> SET ( <replaceable class="parameter">publication_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] )
28
28
ALTER PUBLICATION <replaceable class="parameter">name</replaceable> OWNER TO { <replaceable>new_owner</replaceable> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
29
29
ALTER PUBLICATION <replaceable class="parameter">name</replaceable> RENAME TO <replaceable>new_name</replaceable>
30
+
31
+ <phrase>where <replaceable class="parameter">publication_object</replaceable> is one of:</phrase>
32
+
33
+ TABLE [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ] [, ... ]
34
+ ALL TABLES IN SCHEMA { <replaceable class="parameter">schema_name</replaceable> | CURRENT_SCHEMA } [, ... ]
30
35
</synopsis>
31
36
</refsynopsisdiv>
32
37
@@ -39,14 +44,15 @@ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> RENAME TO <r
39
44
</para>
40
45
41
46
<para>
42
- The first three variants change which tables are part of the publication.
43
- The <literal>SET TABLE</literal> clause will replace the list of tables in
44
- the publication with the specified one. The <literal>ADD TABLE</literal>
45
- and <literal>DROP TABLE</literal> clauses will add and remove one or more
46
- tables from the publication. Note that adding tables to a publication that
47
- is already subscribed to will require a <literal>ALTER SUBSCRIPTION
48
- ... REFRESH PUBLICATION</literal> action on the subscribing side in order
49
- to become effective.
47
+ The first three variants change which tables/schemas are part of the
48
+ publication. The <literal>SET</literal> clause will replace the list of
49
+ tables/schemas in the publication with the specified list; the existing
50
+ tables/schemas that were present in the publication will be removed. The
51
+ <literal>ADD</literal> and <literal>DROP</literal> clauses will add and
52
+ remove one or more tables/schemas from the publication. Note that adding
53
+ tables/schemas to a publication that is already subscribed to will require a
54
+ <literal>ALTER SUBSCRIPTION ... REFRESH PUBLICATION</literal> action on the
55
+ subscribing side in order to become effective.
50
56
</para>
51
57
52
58
<para>
@@ -63,11 +69,22 @@ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> RENAME TO <r
63
69
<para>
64
70
You must own the publication to use <command>ALTER PUBLICATION</command>.
65
71
Adding a table to a publication additionally requires owning that table.
66
- To alter the owner, you must also be a direct or indirect member of the new
67
- owning role. The new owner must have <literal>CREATE</literal> privilege on
68
- the database. Also, the new owner of a <literal>FOR ALL TABLES</literal>
69
- publication must be a superuser. However, a superuser can change the
70
- ownership of a publication regardless of these restrictions.
72
+ The <literal>ADD ALL TABLES IN SCHEMA</literal> and
73
+ <literal>SET ALL TABLES IN SCHEMA</literal> to a publication requires the
74
+ invoking user to be a superuser. To alter the owner, you must also be a
75
+ direct or indirect member of the new owning role. The new owner must have
76
+ <literal>CREATE</literal> privilege on the database. Also, the new owner
77
+ of a <literal>FOR ALL TABLES</literal> or <literal>FOR ALL TABLES IN
78
+ SCHEMA</literal> publication must be a superuser. However, a superuser can
79
+ change the ownership of a publication regardless of these restrictions.
80
+ </para>
81
+
82
+ <para>
83
+ Adding/Setting a table that is part of schema specified in
84
+ <literal>ALL TABLES IN SCHEMA</literal>, adding/setting a schema to a
85
+ publication that already has a table that is part of specified schema or
86
+ adding/setting a table to a publication that already has a table's schema as
87
+ part of the specified schema is not supported.
71
88
</para>
72
89
</refsect1>
73
90
@@ -97,6 +114,15 @@ ALTER PUBLICATION <replaceable class="parameter">name</replaceable> RENAME TO <r
97
114
</listitem>
98
115
</varlistentry>
99
116
117
+ <varlistentry>
118
+ <term><replaceable class="parameter">schema_name</replaceable></term>
119
+ <listitem>
120
+ <para>
121
+ Name of an existing schema.
122
+ </para>
123
+ </listitem>
124
+ </varlistentry>
125
+
100
126
<varlistentry>
101
127
<term><literal>SET ( <replaceable class="parameter">publication_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] )</literal></term>
102
128
<listitem>
@@ -142,6 +168,25 @@ ALTER PUBLICATION noinsert SET (publish = 'update, delete');
142
168
<programlisting>
143
169
ALTER PUBLICATION mypublication ADD TABLE users, departments;
144
170
</programlisting></para>
171
+
172
+ <para>
173
+ Add schemas <structname>marketing</structname> and
174
+ <structname>sales</structname> to the publication
175
+ <structname>sales_publication</structname>:
176
+ <programlisting>
177
+ ALTER PUBLICATION sales_publication ADD ALL TABLES IN SCHEMA marketing, sales;
178
+ </programlisting>
179
+ </para>
180
+
181
+ <para>
182
+ Add tables <structname>users</structname>,
183
+ <structname>departments</structname> and schema
184
+ <structname>production</structname> to the publication
185
+ <structname>production_publication</structname>:
186
+ <programlisting>
187
+ ALTER PUBLICATION production_publication ADD TABLE users, departments, ALL TABLES IN SCHEMA production;
188
+ </programlisting>
189
+ </para>
145
190
</refsect1>
146
191
147
192
<refsect1>
0 commit comments