Example: Upsert without Specifying Primary Index - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

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 can 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.