25.09.2015 Views

Teradata Parallel Data Pump

Teradata Parallel Data Pump Reference - Teradata Developer ...

Teradata Parallel Data Pump Reference - Teradata Developer ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 3: <strong>Teradata</strong> T<strong>Pump</strong> Commands<br />

DML<br />

The Atomic Upsert Feature<br />

The basic upsert function has been enhanced to support an Atomic upsert capability. This<br />

enhancement permits <strong>Teradata</strong> T<strong>Pump</strong> to perform single-row upserts in a single pass. This<br />

one-pass logic adopts the upsert-handling technique used by MultiLoad. The one-pass logic is<br />

designated Atomic to distinguish the grouping of paired UPDATE and INSERT statements<br />

which are executed as a single SQL statement.<br />

The syntax for Atomic upsert consists of an UPDATE statement and an INSERT statement,<br />

separated by an ELSE keyword.<br />

Existing <strong>Teradata</strong> T<strong>Pump</strong> scripts using the Atomic upsert form do not have to be changed.<br />

<strong>Teradata</strong> T<strong>Pump</strong> will automatically convert the old UPDATE/INSERT pairs to the Atomic<br />

upsert feature whenever appropriate. Any attempts to change this will result in a syntax error.<br />

The new syntax, which can also be used by CLIv2 and BTEQ applications, is dependent on<br />

whether or not the database version, against which the <strong>Teradata</strong> T<strong>Pump</strong> job is run, supports<br />

this feature. If the database does not support Atomic Upsert, <strong>Teradata</strong> T<strong>Pump</strong> reverts to the<br />

earlier logic of sending the INSERT request if an UPDATE request fails.<br />

The three basic constraints on the upsert feature are:<br />

• SAME TABLE: The UPDATE and INSERT statements must specify the same table.<br />

• SAME ROW: The UPDATE and INSERT statements must specify the same row; that is, the<br />

primary index value in the INSERT row must be the same as the primary value in the<br />

targeted UPDATE row.<br />

• HASHED ROW ACCESS: The UPDATE fully specifies the primary index, allowing the<br />

target row to be accessed with a one-AMP hashed operation.<br />

Although <strong>Teradata</strong> T<strong>Pump</strong> does not verify basic upsert constraints, <strong>Teradata</strong> <strong>Data</strong>base will<br />

reject Atomic upsert constructs that fail the constraint test, and notify <strong>Teradata</strong> T<strong>Pump</strong> by<br />

returning an appropriate error message to the client.<br />

If the Atomic Upsert is done on a Temporal table, the optional Temporal qualifier can only be<br />

added before the UPDATE statement.<br />

Other Restrictions on Atomic Upsert Feature<br />

Some of these restrictions concern syntax that is supported in UPDATE and INSERT<br />

statements separately, but not when combined in an Atomic upsert statement. Other<br />

restrictions concern the upsert feature's not supporting certain <strong>Teradata</strong> <strong>Data</strong>base features<br />

such as triggers and join/hash indexes, meaning that the upsert statement cannot be used on<br />

any table utilizing those features.<br />

The following restrictions are not supported by the Atomic upsert feature, and return an error<br />

if submitted to <strong>Teradata</strong> <strong>Data</strong>base:<br />

• INSERT … SELECT: Syntax not supported. The INSERT may not use a subquery to<br />

specify any of the inserted values. Note that support of this syntax is likely to be linked to<br />

support of subqueries in the UPDATE's WHERE clause constraints as described above,<br />

and may involve new syntax features to allow the UPDATE and INSERT to effectively<br />

reference the same subquery.<br />

<strong>Teradata</strong> <strong>Parallel</strong> <strong>Data</strong> <strong>Pump</strong> Reference 125

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!