5757
5858 <para>
5959 <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>,
6161 using the <replaceable class="parameter">data_source</replaceable>.
6262 <command>MERGE</command> provides a single <acronym>SQL</acronym>
6363 statement that can conditionally <command>INSERT</command>,
6868 <para>
6969 First, the <command>MERGE</command> command performs a join
7070 from <replaceable class="parameter">data_source</replaceable> to
71- <replaceable class="parameter">target_table_name</replaceable>
71+ the target table
7272 producing zero or more candidate change rows. For each candidate change
7373 row, the status of <literal>MATCHED</literal> or <literal>NOT MATCHED</literal>
7474 is set just once, after which <literal>WHEN</literal> clauses are evaluated
8383 <command>DELETE</command> commands of the same names. The syntax of
8484 those commands is different, notably that there is no <literal>WHERE</literal>
8585 clause and no table name is specified. All actions refer to the
86- <replaceable class="parameter">target_table_name</replaceable> ,
86+ target table ,
8787 though modifications to other tables may be made using triggers.
8888 </para>
8989
@@ -98,23 +98,27 @@ DELETE
9898 There is no separate <literal>MERGE</literal> privilege.
9999 If you specify an update action, you must have the
100100 <literal>UPDATE</literal> privilege on the column(s)
101- of the<replaceable class="parameter">target_table_name</replaceable>
101+ of thetarget table
102102 that are referred to in the <literal>SET</literal> clause.
103103 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 thetarget table .
105105 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>.
107115 Privileges are tested once at statement start and are checked
108116 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>.
113117 </para>
114118
115119 <para>
116120 <command>MERGE</command> is not supported if the
117- <replaceable class="parameter">target_table_name</replaceable> is a
121+ target table is a
118122 materialized view, foreign table, or if it has any
119123 rules defined on it.
120124 </para>
@@ -175,7 +179,7 @@ DELETE
175179 <para>
176180 A query (<command>SELECT</command> statement or <command>VALUES</command>
177181 statement) that supplies the rows to be merged into the
178- <replaceable class="parameter">target_table_name</replaceable> .
182+ target table .
179183 Refer to the <xref linkend="sql-select"/>
180184 statement or <xref linkend="sql-values"/>
181185 statement for a description of the syntax.
@@ -203,16 +207,15 @@ DELETE
203207 <type>boolean</type> (similar to a <literal>WHERE</literal>
204208 clause) that specifies which rows in the
205209 <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.
208211 </para>
209212 <warning>
210213 <para>
211- Only columns from<replaceable class="parameter">target_table_name</replaceable>
214+ Only columns fromthe target table
212215 that attempt to match <replaceable class="parameter">data_source</replaceable>
213216 rows should appear in <replaceable class="parameter">join_condition</replaceable>.
214217 <replaceable class="parameter">join_condition</replaceable> subexpressions that
215- only reference<replaceable class="parameter">target_table_name</replaceable>
218+ only referencethe target table's
216219 columns can affect which action is taken, often in surprising ways.
217220 </para>
218221 </warning>
@@ -228,7 +231,7 @@ DELETE
228231 <para>
229232 If the <literal>WHEN</literal> clause specifies <literal>WHEN MATCHED</literal>
230233 and the candidate change row matches a row in the
231- <replaceable class="parameter">target_table_name</replaceable> ,
234+ target table ,
232235 the <literal>WHEN</literal> clause is executed if the
233236 <replaceable class="parameter">condition</replaceable> is
234237 absent or it evaluates to <literal>true</literal>.
@@ -237,7 +240,7 @@ DELETE
237240 Conversely, if the <literal>WHEN</literal> clause specifies
238241 <literal>WHEN NOT MATCHED</literal>
239242 and the candidate change row does not match a row in the
240- <replaceable class="parameter">target_table_name</replaceable> ,
243+ target table ,
241244 the <literal>WHEN</literal> clause is executed if the
242245 <replaceable class="parameter">condition</replaceable> is
243246 absent or it evaluates to <literal>true</literal>.
@@ -280,10 +283,10 @@ DELETE
280283 or null if there is none.
281284 </para>
282285 <para>
283- If<replaceable class="parameter">target_table_name</replaceable>
286+ Ifthe target table
284287 is a partitioned table, each row is routed to the appropriate partition
285288 and inserted into it.
286- If<replaceable class="parameter">target_table_name</replaceable>
289+ Ifthe target table
287290 is a partition, an error will occur if any input row violates the
288291 partition constraint.
289292 </para>
@@ -304,7 +307,7 @@ DELETE
304307 <listitem>
305308 <para>
306309 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 thetarget table .
308311 Column names may not be specified more than once.
309312 </para>
310313 <para>
@@ -318,7 +321,7 @@ DELETE
318321 <listitem>
319322 <para>
320323 Specifies a <literal>DELETE</literal> action that deletes the current row
321- of the<replaceable class="parameter">target_table_name</replaceable> .
324+ of thetarget table .
322325 Do not include the table name or any other clauses, as you would normally
323326 do with a <xref linkend="sql-delete"/> command.
324327 </para>
@@ -329,8 +332,7 @@ DELETE
329332 <term><replaceable class="parameter">column_name</replaceable></term>
330333 <listitem>
331334 <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
334336 can be qualified with a subfield name or array subscript, if
335337 needed. (Inserting into only some fields of a composite
336338 column leaves the other fields null.)