Example: INSERT Using a Scalar Subquery - Analytics Database - Teradata Vantage

SQL Data Manipulation Language

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-04-02
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
Product Category
Teradata Vantageā„¢

A scalar subquery can be specified as a parameterized value in the value list of a simple INSERT request, but Vantage always interprets it as a noncorrelated scalar subquery.

For example, the database processes the scalar subquery SELECT d2 FROM t2 WHERE a2=t1.a1 in the select list of the following INSERT request as if it were SELECT d2 FROM t2, t1 WHERE a2=t1.a1.

In other words, the database interprets t1 in the scalar subquery as a distinct instance of t1 rather than as the target table t1 of the insert operation.

     INSERT INTO t1 VALUES (1,2,3 (SELECT d2
                                   FROM t2
                                   WHERE a2=t1.a1));