Example: Left Outer Join Usage - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
ft:locale
en-US
ft:lastEdition
2021-07-27
dita:mapPath
spp1591731285373.ditamap
dita:ditavalPath
spp1591731285373.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™

The first recursive view definition demonstrates a correct use of a left outer join, which is highlighted in bold. The usage is valid because the recursive relation in the recursive statement of the view definition is used as the outer relation in the left outer join.

    CREATE RECURSIVE VIEW rec (f1, mycount) AS (       SELECT a1, 0 AS mycount       FROM nonrec     UNION ALL       SELECT a2, mycount + 1       FROM rec LEFT OUTER JOIN nonrec ON nonrec.a1 = rec.f1       WHERE rec.mycount <= 100);

The second recursive view definition demonstrates a non-valid use of a left outer join, which is highlighted in bold. The usage is not valid because the recursive relation in the recursive statement of the view definition is used as the inner relation in the left outer join.

    CREATE RECURSIVE VIEW rec (f1, mycount) AS (       SELECT a1, 0 AS mycount       FROM nonrec     UNION ALL       SELECT a2, mycount + 1       FROM nonrec LEFT OUTER JOIN rec ON nonrec.a1 = rec.f1       WHERE rec.mycount <= 100);

You can use left outer joins without restriction in the seed statement of a recursive view definition.