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.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
wgr1555383704548.ditamap
dita:ditavalPath
lze1555437562152.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