Example: Simple REPLACE 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 following example replaces the existing definition for the recursive view named rec with the specified SQL code:

    REPLACE RECURSIVE VIEW rec(p, mycount) AS (
      SELECT n, 0 AS mycount
      FROM t
      WHERE n = 1
    UNION ALL
      SELECT rec.p, rec.mycount + 1
      FROM t, rec
      WHERE rec.p = t.n
      AND   rec.mycount <= 20