From 583905269378bf41c24585773885b1e226a998ce Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 31 Jan 2013 22:31:58 -0500 Subject: Add CREATE RECURSIVE VIEW syntax This is specified in the SQL standard. The CREATE RECURSIVE VIEW specification is transformed into a normal CREATE VIEW statement with a WITH RECURSIVE clause. reviewed by Abhijit Menon-Sen and Stephen Frost --- doc/src/sgml/ref/create_view.sgml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'doc/src') diff --git a/doc/src/sgml/ref/create_view.sgml b/doc/src/sgml/ref/create_view.sgml index abbde94772c..0745e3cdb59 100644 --- a/doc/src/sgml/ref/create_view.sgml +++ b/doc/src/sgml/ref/create_view.sgml @@ -21,7 +21,7 @@ PostgreSQL documentation -CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] VIEW name [ ( column_name [, ...] ) ] +CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] [ RECURSIVE ] VIEW name [ ( column_name [, ...] ) ] [ WITH ( view_option_name [= view_option_value] [, ... ] ) ] AS query @@ -80,6 +80,23 @@ CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] VIEW n + + RECURSIVE + + + Creates a recursive view. The syntax + +CREATE RECURSIVE VIEW name (columns) AS SELECT ...; + + is equivalent to + +CREATE VIEW name AS WITH RECURSIVE name (columns) AS (SELECT ...) SELECT columns FROM name; + + A view column list must be specified for a recursive view. + + + + name @@ -282,6 +299,16 @@ CREATE VIEW comedies AS * was used to create the view, columns added later to the table will not be part of the view. + + + Create a recursive view consisting of the numbers from 1 to 100: + +CREATE RECURSIVE VIEW nums_1_100 (n) AS + VALUES (1) +UNION ALL + SELECT n+1 FROM nums_1_100 WHERE n < 100; + + -- cgit v1.2.3