aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2013-01-31 22:31:58 -0500
committerPeter Eisentraut <peter_e@gmx.net>2013-01-31 22:31:58 -0500
commit583905269378bf41c24585773885b1e226a998ce (patch)
tree0e71e7a73c716f1b6fc00840af5642dd73fd2878 /doc/src
parentb1980f6d03f79ab57da8f32aa8cd9677dbe1d58f (diff)
downloadpostgresql-583905269378bf41c24585773885b1e226a998ce.tar.gz
postgresql-583905269378bf41c24585773885b1e226a998ce.zip
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
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/ref/create_view.sgml29
1 files changed, 28 insertions, 1 deletions
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
<refsynopsisdiv>
<synopsis>
-CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] VIEW <replaceable class="PARAMETER">name</replaceable> [ ( <replaceable class="PARAMETER">column_name</replaceable> [, ...] ) ]
+CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] [ RECURSIVE ] VIEW <replaceable class="PARAMETER">name</replaceable> [ ( <replaceable class="PARAMETER">column_name</replaceable> [, ...] ) ]
[ WITH ( <replaceable class="PARAMETER">view_option_name</replaceable> [= <replaceable class="PARAMETER">view_option_value</replaceable>] [, ... ] ) ]
AS <replaceable class="PARAMETER">query</replaceable>
</synopsis>
@@ -81,6 +81,23 @@ CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] VIEW <replaceable class="PARAMETER">n
</varlistentry>
<varlistentry>
+ <term><literal>RECURSIVE</></term>
+ <listitem>
+ <para>
+ Creates a recursive view. The syntax
+<synopsis>
+CREATE RECURSIVE VIEW <replaceable>name</> (<replaceable>columns</>) AS SELECT <replaceable>...</>;
+</synopsis>
+ is equivalent to
+<synopsis>
+CREATE VIEW <replaceable>name</> AS WITH RECURSIVE <replaceable>name</> (<replaceable>columns</>) AS (SELECT <replaceable>...</>) SELECT <replaceable>columns</> FROM <replaceable>name</>;
+</synopsis>
+ A view column list must be specified for a recursive view.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><replaceable class="parameter">name</replaceable></term>
<listitem>
<para>
@@ -282,6 +299,16 @@ CREATE VIEW comedies AS
<literal>*</> was used to create the view, columns added later to
the table will not be part of the view.
</para>
+
+ <para>
+ Create a recursive view consisting of the numbers from 1 to 100:
+<programlisting>
+CREATE RECURSIVE VIEW nums_1_100 (n) AS
+ VALUES (1)
+UNION ALL
+ SELECT n+1 FROM nums_1_100 WHERE n < 100;
+</programlisting>
+ </para>
</refsect1>
<refsect1>