Example: Upsert Insert - 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 a valid upsert INSERT request.

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

After all of the rules have been validated and no row was found that satisfies the compound predicate item = 20 and sale_date = ‘05/30/2000’ for the update, a new row is inserted with item_nbr = 20.

A message indicates the successful insert of one row.