15.10 - Example: RECURSIVE Specified for a Non-Recursive View - Teradata Database

Teradata Database SQL Data Definition Language Syntax and Examples

prodname
Teradata Database
vrm_release
15.10
created_date
December 2015
category
Programming Reference
featnum
B035-1144-151K

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.