57
57
58
58
<para>
59
59
<command>MERGE</command> performs actions that modify rows in the
60
- <replaceable class="parameter">target_table_name</replaceable>,
60
+ target table identified as <replaceable class="parameter">target_table_name</replaceable>,
61
61
using the <replaceable class="parameter">data_source</replaceable>.
62
62
<command>MERGE</command> provides a single <acronym>SQL</acronym>
63
63
statement that can conditionally <command>INSERT</command>,
68
68
<para>
69
69
First, the <command>MERGE</command> command performs a join
70
70
from <replaceable class="parameter">data_source</replaceable> to
71
- <replaceable class="parameter">target_table_name</replaceable>
71
+ the target table
72
72
producing zero or more candidate change rows. For each candidate change
73
73
row, the status of <literal>MATCHED</literal> or <literal>NOT MATCHED</literal>
74
74
is set just once, after which <literal>WHEN</literal> clauses are evaluated
83
83
<command>DELETE</command> commands of the same names. The syntax of
84
84
those commands is different, notably that there is no <literal>WHERE</literal>
85
85
clause and no table name is specified. All actions refer to the
86
- <replaceable class="parameter">target_table_name</replaceable> ,
86
+ target table ,
87
87
though modifications to other tables may be made using triggers.
88
88
</para>
89
89
@@ -98,23 +98,27 @@ DELETE
98
98
There is no separate <literal>MERGE</literal> privilege.
99
99
If you specify an update action, you must have the
100
100
<literal>UPDATE</literal> privilege on the column(s)
101
- of the <replaceable class="parameter">target_table_name</replaceable>
101
+ of the target table
102
102
that are referred to in the <literal>SET</literal> clause.
103
103
If you specify an insert action, you must have the <literal>INSERT</literal>
104
- privilege on the <replaceable class="parameter">target_table_name</replaceable> .
104
+ privilege on the target table .
105
105
If you specify a delete action, you must have the <literal>DELETE</literal>
106
- privilege on the <replaceable class="parameter">target_table_name</replaceable>.
106
+ privilege on the target table.
107
+ If you specify a <literal>DO NOTHING</literal> action, you must have
108
+ the <literal>SELECT</literal> privilege on at least one column
109
+ of the target table.
110
+ You will also need <literal>SELECT</literal> privilege on any column(s)
111
+ of the <replaceable class="parameter">data_source</replaceable> and
112
+ of the target table referred to
113
+ in any <literal>condition</literal> (including <literal>join_condition</literal>)
114
+ or <literal>expression</literal>.
107
115
Privileges are tested once at statement start and are checked
108
116
whether or not particular <literal>WHEN</literal> clauses are executed.
109
- You will require the <literal>SELECT</literal> privilege on any column(s)
110
- of the <replaceable class="parameter">data_source</replaceable> and
111
- <replaceable class="parameter">target_table_name</replaceable> referred to
112
- in any <literal>condition</literal> or <literal>expression</literal>.
113
117
</para>
114
118
115
119
<para>
116
120
<command>MERGE</command> is not supported if the
117
- <replaceable class="parameter">target_table_name</replaceable> is a
121
+ target table is a
118
122
materialized view, foreign table, or if it has any
119
123
rules defined on it.
120
124
</para>
@@ -175,7 +179,7 @@ DELETE
175
179
<para>
176
180
A query (<command>SELECT</command> statement or <command>VALUES</command>
177
181
statement) that supplies the rows to be merged into the
178
- <replaceable class="parameter">target_table_name</replaceable> .
182
+ target table .
179
183
Refer to the <xref linkend="sql-select"/>
180
184
statement or <xref linkend="sql-values"/>
181
185
statement for a description of the syntax.
@@ -203,16 +207,15 @@ DELETE
203
207
<type>boolean</type> (similar to a <literal>WHERE</literal>
204
208
clause) that specifies which rows in the
205
209
<replaceable class="parameter">data_source</replaceable>
206
- match rows in the
207
- <replaceable class="parameter">target_table_name</replaceable>.
210
+ match rows in the target table.
208
211
</para>
209
212
<warning>
210
213
<para>
211
- Only columns from <replaceable class="parameter">target_table_name</replaceable>
214
+ Only columns from the target table
212
215
that attempt to match <replaceable class="parameter">data_source</replaceable>
213
216
rows should appear in <replaceable class="parameter">join_condition</replaceable>.
214
217
<replaceable class="parameter">join_condition</replaceable> subexpressions that
215
- only reference <replaceable class="parameter">target_table_name</replaceable>
218
+ only reference the target table's
216
219
columns can affect which action is taken, often in surprising ways.
217
220
</para>
218
221
</warning>
@@ -228,7 +231,7 @@ DELETE
228
231
<para>
229
232
If the <literal>WHEN</literal> clause specifies <literal>WHEN MATCHED</literal>
230
233
and the candidate change row matches a row in the
231
- <replaceable class="parameter">target_table_name</replaceable> ,
234
+ target table ,
232
235
the <literal>WHEN</literal> clause is executed if the
233
236
<replaceable class="parameter">condition</replaceable> is
234
237
absent or it evaluates to <literal>true</literal>.
@@ -237,7 +240,7 @@ DELETE
237
240
Conversely, if the <literal>WHEN</literal> clause specifies
238
241
<literal>WHEN NOT MATCHED</literal>
239
242
and the candidate change row does not match a row in the
240
- <replaceable class="parameter">target_table_name</replaceable> ,
243
+ target table ,
241
244
the <literal>WHEN</literal> clause is executed if the
242
245
<replaceable class="parameter">condition</replaceable> is
243
246
absent or it evaluates to <literal>true</literal>.
@@ -280,10 +283,10 @@ DELETE
280
283
or null if there is none.
281
284
</para>
282
285
<para>
283
- If <replaceable class="parameter">target_table_name</replaceable>
286
+ If the target table
284
287
is a partitioned table, each row is routed to the appropriate partition
285
288
and inserted into it.
286
- If <replaceable class="parameter">target_table_name</replaceable>
289
+ If the target table
287
290
is a partition, an error will occur if any input row violates the
288
291
partition constraint.
289
292
</para>
@@ -304,7 +307,7 @@ DELETE
304
307
<listitem>
305
308
<para>
306
309
The specification of an <literal>UPDATE</literal> action that updates
307
- the current row of the <replaceable class="parameter">target_table_name</replaceable> .
310
+ the current row of the target table .
308
311
Column names may not be specified more than once.
309
312
</para>
310
313
<para>
@@ -318,7 +321,7 @@ DELETE
318
321
<listitem>
319
322
<para>
320
323
Specifies a <literal>DELETE</literal> action that deletes the current row
321
- of the <replaceable class="parameter">target_table_name</replaceable> .
324
+ of the target table .
322
325
Do not include the table name or any other clauses, as you would normally
323
326
do with a <xref linkend="sql-delete"/> command.
324
327
</para>
@@ -329,8 +332,7 @@ DELETE
329
332
<term><replaceable class="parameter">column_name</replaceable></term>
330
333
<listitem>
331
334
<para>
332
- The name of a column in the <replaceable
333
- class="parameter">target_table_name</replaceable>. The column name
335
+ The name of a column in the target table. The column name
334
336
can be qualified with a subfield name or array subscript, if
335
337
needed. (Inserting into only some fields of a composite
336
338
column leaves the other fields null.)
0 commit comments