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 />

UPDATE Statement and Atomic Upsert<br />

used in other ways with Atomic upsert statements. For example, a DECLARE CURSOR<br />

statement may include upsert statements among those to be executed when the cursor is<br />

opened, as long as the upserts are otherwise valid.<br />

• UPDATE-FROM: Not supported. The SET clause cannot use a FROM clause table<br />

reference in the expression for the updated value for a column.<br />

• UPDATE-WHERE SUBQUERIES: Not supported. The WHERE clause cannot use a<br />

subquery either to specify the primary index or to constrain a nonindex column. Note that<br />

supporting this UPDATE syntax would also require support for either INSERT … SELECT<br />

or some other INSERT syntax feature that lets it specify the same primary index value as<br />

the UPDATE.<br />

• UPDATE-PRIMARY INDEX: Not supported. The UPDATE cannot change the primary<br />

index. This is sometime called unreasonable update.<br />

• TRIGGERS: Feature not supported if either the UPDATE or INSERT could cause a trigger<br />

to be fired. The restriction applies as if the UPDATE and INSERT were both executed,<br />

because the parser trigger logic will not attempt to account for their conditional execution.<br />

UPDATE triggers on columns not referenced by the UPDATE clause, however, will never<br />

be fired by the upsert and are therefore permitted. DELETE triggers cannot be fired at all<br />

by an upsert and are likewise permitted. Note that an upsert could be used as a trigger<br />

action but it would be subject to the same constraints as any other upsert. Because upsert<br />

is not allowed to fire any triggers itself, an upsert trigger action must not generate any<br />

further cascaded trigger actions.<br />

• JOIN/HASH INDEXES: Feature not supported if either the UPDATE or INSERT could<br />

cause the join/hash index to be updated. As with triggers, the restriction applies to each<br />

upsert as if the UPDATE and INSERT were both executed. While the UPDATE could<br />

escape this restriction if the join/hash index does not reference any of the updated<br />

columns, it is much less likely (and maybe impossible) for the INSERT to escape this<br />

restriction. If the benefit of lifting the restriction for a few unlikely join/hash index cases<br />

turns out to be not worth the implementation cost, the restriction may have to be applied<br />

more broadly to any table with an associated join/hash index.<br />

<strong>Teradata</strong> T<strong>Pump</strong> treats a failed constraint as a nonfatal error, reports the error in the job log<br />

for diagnostic purposes, and continues with the job by reverting to nonbasic upsert protocol.<br />

To resolve order-dependency issues, <strong>Teradata</strong> T<strong>Pump</strong> always processes the UPDATE before the<br />

INSERT because:<br />

• It matches the ordering implied by the upsert name: UP[date] + [in]SERT.<br />

• It matches the ordering implied by the UPDATE-ELSE-INSERT syntax.<br />

• It matches the common definition of upsert semantics.<br />

• It allows for an upsert operation on MULTISET tables, where an insert-first policy would<br />

always succeed on INSERT and never on UPDATE.<br />

Existing <strong>Teradata</strong> T<strong>Pump</strong> scripts for upsert do not need to be changed. The syntax as<br />

described below for upsert will continue to be supported:<br />

DO INSERT FOR MISSING UPDATE ROWS;<br />

UPDATE ;<br />

INSERT ;<br />

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

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

Saved successfully!

Ooh no, something went wrong!