17.10 - Example: Simple REPLACE 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.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1144-171K
Language
English (United States)

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