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

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Published
January 2021
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
ncd1596241368722.ditamap
dita:ditavalPath
hoy1596145193032.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™

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.