MERGE Statement Processing - Teradata Database

SQL Data Manipulation Language

Product
Teradata Database
Release Number
15.10
Language
English (United States)
Last Update
2018-10-06
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata® Database

This section describes the general actions performed by a MERGE statement:

The Venn diagram below divides the source table rows into two disjunct sets: set A and set B. Set A is the set of matching rows and set B is the set of nonmatching rows.

This description uses the following terms:

  • The target_table variable specifies the target table being modified.
  • The correlation_name variable is an optional alias for the target table.
  • The source_table_name variable following the USING keyword specifies the source table whose rows act as the source for update or delete and insert operations.
  • The match_condition variable following the ON keyword divides the source table into a set of rows that match rows in the target table and a set of rows that do not match rows in the target table.
  • The set of matching rows, A, defines the update or delete source, or staging, table.

    The set of nonmatching rows, B, defines the insert source, or staging, table.

    Either set can be empty, but both cannot be empty for a MERGE operation.

    The system uses the set of matching rows as the update or delete source table for the update operation, as specified by the update_column=update_expression variable.

    The system uses the set of nonmatching rows as the insert source table for the insert operation, as specified by the insert_expression variable.