Example: Upsert Without Specifying Primary Index - Teradata Database - Teradata Vantage NewSQL Engine

SQL Data Manipulation Language

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-03
dita:mapPath
fbo1512081269404.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.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.