17.05 - Example: With a Guaranteed Single-Row Source Relation, You Do Not Need To Specify the Partitioning Column Set - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1146-175K
Language
English (United States)

Because the following MERGE request guarantees a single-row source relation by specifying an equality condition on the USI of target RPPI table t1, it is not necessary to specify the partitioning column set:

     CREATE TABLE t1 (
       a1 INTEGER,
       b1 INTEGER,
       c1 INTEGER)
     PRIMARY INDEX (a1)
     PARTITION BY b1;

     CREATE TABLE t2 (
       a2 INTEGER,
       b2 INTEGER,
       c2 INTEGER)
     PRIMARY INDEX (a2),
     UNIQUE INDEX(b2);
     MERGE INTO t1
       USING (SELECT *
              FROM t2
              WHERE b2=10) AS s
       ON a1=1
     WHEN MATCHED THEN
       UPDATE SET c1=c2
     WHEN NOT MATCHED THEN
       INSERT (c2, b2, c2);