16.20 - Example: Right Outer Join Usage - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantage™ SQL Data Definition Language Syntax and Examples

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-24
dita:mapPath
wkf1512081455740.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval

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

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

The second recursive view definition demonstrates a non-valid use of a right outer join, which is highlighted in bold typeface. 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 right outer join.

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

Right outer joins can be used without restriction in the seed statement of a recursive view definition.