MERGE INSERT Duplicate Rows - 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

When MERGE detects duplicate rows during an INSERT operation, then Teradata Database takes different actions on the request depending on several factors.

  • If no error logging is specified for the request AND the target table is a SET table AND the session is in ANSI session mode, then the request aborts and rolls back.
  • If error logging is specified for the request AND the target table is a SET table AND the session is in ANSI session mode, then the request aborts and rolls back if there are any nonlocal errors, but only after the MERGE request completes or the specified error limit is reached.
  • Error‑causing rows are logged in an error table and are not rolled back.

  • If the target table is a SET table AND the session is in Teradata session mode, then any duplicate rows are silently ignored.
  • The INSERT source relation for a MERGE statement can contain duplicate rows.

    Like the case for an INSERT … SELECT statement, MERGE silently ignores duplicate row INSERT attempts into a SET table in Teradata session mode.

    When the system inserts rows into the target table, the insertion of duplicate rows is governed by the normal constraint check rules enforced by the session mode types:

     

    IN this session mode …

    The system handles duplicate row insert attempts by …

    ANSI

    not inserting them into the target table.

    It logs them as errors in the appropriate error table.

    The system inserts no rows into the target table under these circumstances.

    Teradata

    inserting the first row of the duplicate set into the target table and rejecting all the remaining rows from that set without logging them as errors.

    The system inserts one row into the target table under these circumstances.

    Unlike an INSERT … SELECT statement, MERGE does not silently ignore duplicate row insert attempts into a SET table in Teradata session mode.