Example: RECURSIVE Specified for a Non-Recursive View - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

The view definition in the following example does not contain a reference to the recursive relation, rec, inside its own definition. Because of that omission, even though the statement specifies the keyword RECURSIVE, the definition does not define a recursive view. The result is that the view definition specifies a normal, non-recursive, view.

    REPLACE RECURSIVE VIEW rec (p) AS (
      SELECT n
      FROM t
      WHERE n = 1
    UNION ALL
      SELECT t.n
      FROM t
      WHERE t.n = 0;

The RECURSIVE keyword means only that a view definition is potentially recursive. This is analogous to the situation where a query written with an outer join specification only potentially makes an outer join, and, depending on how the conditions are specified,may make only an inner join.

Conversely, if you do not specify the RECURSIVE keyword, then the view cannot be recursive.