Example: Upsert Without Specifying Primary Index - Advanced SQL Engine - Teradata Database

SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
vjt1596846980081.ditamap
dita:ditavalPath
vjt1596846980081.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantageā„¢

This example shows an upsert UPDATE request that does not specify the primary index in its WHERE clause.

     UPDATE sales
     SET item_count = item_count + 1
     WHERE sale_date = '05/30/2000'
     ELSE INSERT INTO sales (10, '05/30/2000', 1);

When the primary index is not specified in the UPDATE portion of an upsert request, the operation could have to perform an all-row scan to find rows to update. This is not the purpose of upsert form of UPDATE. This case returns an error.