Re: Create recursive view schema.name

Lele Gaifax <lele@metapensiero.it>

From: Lele Gaifax <lele@metapensiero.it>
To: pgsql-general@postgresql.org
Date: 2016-10-11T14:12:58Z
Lists: pgsql-general
Tom Lane <tgl@sss.pgh.pa.us> writes:

> The manual says
> 	CREATE RECURSIVE VIEW name (columns) AS SELECT ...;
> 	is equivalent to
> 	CREATE VIEW name AS WITH RECURSIVE name (columns) AS (SELECT ...) SELECT columns FROM name;
>
> I guess it could be more explicit about the fact that the implied CTE just
> has the base name of the view; but since CTE names can't be qualified,
> that's not that hard to guess.  Short answer is that you don't qualify the
> view's internal self-reference, even if you are using a schema name in the
> CREATE.

Thank you Tom, it works.

I agree with you that the doc could/should be fixed/enhanced, because the
explanation of "name" is immediately following the snippet you cited, and it
says "The name (optionally schema-qualified) of a view to be created": it
would never occurred to me that I could use a not-qualified name within the
view.

bye, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele@metapensiero.it  |                 -- Fortunato Depero, 1929.