17.00 - Example: RECURSIVE Specified for a Non-Recursive View - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Release Date
September 2020
Content Type
Programming Reference
Publication ID
B035-1144-170K
Language
English (United States)

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, it 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, might make only an inner join.

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