head	1.43;
access;
symbols
	REL9_0_0:1.43
	REL9_1_ALPHA1:1.43
	REL9_0_RC1:1.43
	REL9_0_BETA4:1.43
	REL9_0_STABLE:1.43.0.2
	REL9_0_BETA3:1.43
	REL9_0_BETA2:1.43
	REL7_4_29:1.27
	REL8_0_25:1.29
	REL8_1_21:1.31.2.1
	REL8_2_17:1.33.2.1
	REL8_3_11:1.36.2.1
	REL8_4_4:1.41.2.1
	REL9_0_BETA1:1.43
	REL9_0_ALPHA5_BRANCH:1.42.0.8
	REL9_0_ALPHA5:1.42
	REL7_4_28:1.27
	REL8_0_24:1.29
	REL8_1_20:1.31.2.1
	REL8_2_16:1.33.2.1
	REL8_3_10:1.36.2.1
	REL8_4_3:1.41.2.1
	REL9_0_ALPHA4:1.42
	REL9_0_ALPHA4_BRANCH:1.42.0.6
	REL8_5_ALPHA3:1.42
	REL8_5_ALPHA3_BRANCH:1.42.0.4
	REL7_4_27:1.27
	REL8_0_23:1.29
	REL8_1_19:1.31.2.1
	REL8_2_15:1.33.2.1
	REL8_3_9:1.36.2.1
	REL8_4_2:1.41.2.1
	REL8_5_ALPHA2:1.42
	REL8_5_ALPHA2_BRANCH:1.42.0.2
	REL7_4_26:1.27
	REL8_0_22:1.29
	REL8_1_18:1.31
	REL8_2_14:1.33
	REL8_3_8:1.36
	REL8_4_1:1.41
	REL8_5_ALPHA1:1.41
	REL8_5_ALPHA1_BRANCH:1.41.0.4
	REL8_4_STABLE:1.41.0.2
	REL8_4_0:1.41
	REL8_4_RC2:1.41
	REL8_4_RC1:1.41
	REL8_4_BETA2:1.41
	REL8_4_BETA1:1.41
	REL7_4_25:1.27
	REL8_0_21:1.29
	REL8_1_17:1.31
	REL8_2_13:1.33
	REL8_3_7:1.36
	REL7_4_24:1.27
	REL8_0_20:1.29
	REL8_1_16:1.31
	REL8_2_12:1.33
	REL8_3_6:1.36
	REL7_4_23:1.27
	REL8_0_19:1.29
	REL8_1_15:1.31
	REL8_2_11:1.33
	REL8_3_5:1.36
	REL7_4_22:1.27
	REL8_0_18:1.29
	REL8_1_14:1.31
	REL8_2_10:1.33
	REL8_3_4:1.36
	REL7_4_21:1.27
	REL8_0_17:1.29
	REL8_1_13:1.31
	REL8_2_9:1.33
	REL8_3_3:1.36
	REL7_4_20:1.27
	REL8_0_16:1.29
	REL8_1_12:1.31
	REL8_2_8:1.33
	REL8_3_2:1.36
	REL8_2_7:1.33
	REL8_3_1:1.36
	REL8_3_STABLE:1.36.0.2
	REL8_3_0:1.36
	REL8_3_RC2:1.36
	REL7_3_21:1.20.2.1
	REL7_4_19:1.27
	REL8_0_15:1.29
	REL8_1_11:1.31
	REL8_2_6:1.33
	REL8_3_RC1:1.36
	REL8_3_BETA4:1.36
	REL8_3_BETA3:1.36
	REL8_3_BETA2:1.36
	REL8_3_BETA1:1.36
	REL7_3_20:1.20.2.1
	REL7_4_18:1.27
	REL8_0_14:1.29
	REL8_1_10:1.31
	REL8_2_5:1.33
	REL7_3_19:1.20.2.1
	REL7_4_17:1.27
	REL8_0_13:1.29
	REL8_1_9:1.31
	REL8_2_4:1.33
	REL8_0_12:1.29
	REL8_1_8:1.31
	REL8_2_3:1.33
	REL7_3_18:1.20.2.1
	REL7_4_16:1.27
	REL8_0_11:1.29
	REL8_1_7:1.31
	REL8_2_2:1.33
	REL8_0_10:1.29
	REL8_1_6:1.31
	REL8_2_1:1.33
	REL7_4_15:1.27
	REL7_3_17:1.20.2.1
	REL8_2_STABLE:1.33.0.2
	REL8_2_0:1.33
	REL8_2_RC1:1.33
	REL8_2_BETA3:1.33
	REL8_2_BETA2:1.33
	REL8_1_5:1.31
	REL8_0_9:1.29
	REL7_4_14:1.27
	REL7_3_16:1.20.2.1
	REL8_2_BETA1:1.33
	REL7_3_15:1.20.2.1
	REL7_4_13:1.27
	REL8_0_8:1.29
	REL8_1_4:1.31
	REL7_3_14:1.20.2.1
	REL7_4_12:1.27
	REL8_0_7:1.29
	REL8_1_3:1.31
	REL7_3_13:1.20.2.1
	REL7_4_11:1.27
	REL8_0_6:1.29
	REL8_1_2:1.31
	REL7_3_12:1.20.2.1
	REL7_4_10:1.27
	REL8_0_5:1.29
	REL8_1_1:1.31
	REL8_1_STABLE:1.31.0.2
	REL8_1_0:1.31
	REL8_1_0RC1:1.30
	REL8_1_0BETA4:1.30
	REL8_1_0BETA3:1.30
	REL7_3_11:1.20.2.1
	REL7_4_9:1.27
	REL8_0_4:1.29
	REL8_1_0BETA2:1.30
	REL8_1_0BETA1:1.30
	REL7_2_8:1.14
	REL7_3_10:1.20.2.1
	REL7_4_8:1.27
	REL8_0_3:1.29
	REL8_0_2:1.29
	REL7_2_7:1.14
	REL7_3_9:1.20.2.1
	REL7_4_7:1.27
	REL8_0_1:1.29
	REL8_0_STABLE:1.29.0.4
	REL8_0_0:1.29.0.2
	REL8_0_0RC5:1.29
	REL8_0_0RC4:1.29
	REL8_0_0RC3:1.28
	REL8_0_0RC2:1.28
	REL8_0_0RC1:1.28
	REL8_0_0BETA5:1.28
	REL8_0_0BETA4:1.28
	REL7_4_6:1.27
	REL7_3_8:1.20.2.1
	REL7_2_6:1.14
	REL8_0_0BETA3:1.28
	REL8_0_0BETA2:1.28
	REL7_2_5:1.14
	REL7_4_5:1.27
	REL7_3_7:1.20.2.1
	REL7_4_4:1.27
	REL8_0_0BETA1:1.28
	REL7_4_3:1.27
	REL7_4_2:1.27
	REL7_3_6:1.20.2.1
	REL7_4_1:1.27
	REL7_3_5:1.20.2.1
	REL7_4:1.27
	REL7_4_RC2:1.27
	REL7_4_STABLE:1.27.0.2
	REL7_4_RC1:1.27
	REL7_4_BETA5:1.26
	REL7_4_BETA4:1.26
	REL7_4_BETA3:1.24
	REL7_4_BETA2:1.22
	WIN32_DEV:1.22.0.2
	REL7_4_BETA1:1.22
	REL7_3_4:1.20.2.1
	REL7_3_2:1.20.2.1
	REL7_2_4:1.14
	REL7_3_STABLE:1.20.0.2
	REL7_2_3:1.14
	REL7_2_STABLE:1.14.0.2
	REL7_2:1.14
	REL7_2_RC2:1.14
	REL7_2_RC1:1.14
	REL7_2_BETA5:1.14
	REL7_2_BETA4:1.14
	REL7_2_BETA3:1.13
	REL7_2_BETA2:1.12
	REL7_2_BETA1:1.12
	REL7_1_2:1.10
	REL7_1_STABLE:1.10.0.2
	REL7_1_BETA:1.9
	REL7_1_BETA3:1.9
	REL7_1_BETA2:1.9
	REL7_1:1.10
	REL7_0_PATCHES:1.9.0.2
	REL7_0:1.9
	REL6_5_PATCHES:1.6.0.2
	REL6_5:1.6
	REL6_4:1.4.0.2;
locks; strict;
comment	@# @;


1.43
date	2010.04.03.07.23.00;	author petere;	state Exp;
branches;
next	1.42;

1.42
date	2009.10.02.18.13.04;	author tgl;	state Exp;
branches;
next	1.41;

1.41
date	2009.01.27.12.40.15;	author petere;	state Exp;
branches
	1.41.2.1;
next	1.40;

1.40
date	2009.01.22.17.27.54;	author petere;	state Exp;
branches;
next	1.39;

1.39
date	2008.12.15.21.35.31;	author tgl;	state Exp;
branches;
next	1.38;

1.38
date	2008.12.06.23.22.46;	author momjian;	state Exp;
branches;
next	1.37;

1.37
date	2008.11.14.10.22.46;	author petere;	state Exp;
branches;
next	1.36;

1.36
date	2007.07.03.01.30.35;	author neilc;	state Exp;
branches
	1.36.2.1;
next	1.35;

1.35
date	2007.02.01.00.28.18;	author momjian;	state Exp;
branches;
next	1.34;

1.34
date	2007.01.31.23.26.03;	author momjian;	state Exp;
branches;
next	1.33;

1.33
date	2006.09.18.19.54.01;	author tgl;	state Exp;
branches
	1.33.2.1;
next	1.32;

1.32
date	2006.09.16.00.30.17;	author momjian;	state Exp;
branches;
next	1.31;

1.31
date	2005.11.01.21.09.50;	author tgl;	state Exp;
branches
	1.31.2.1;
next	1.30;

1.30
date	2005.02.02.06.35.59;	author neilc;	state Exp;
branches;
next	1.29;

1.29
date	2005.01.04.00.39.53;	author tgl;	state Exp;
branches;
next	1.28;

1.28
date	2003.11.29.19.51.38;	author pgsql;	state Exp;
branches;
next	1.27;

1.27
date	2003.11.01.01.56.29;	author petere;	state Exp;
branches;
next	1.26;

1.26
date	2003.09.28.01.19.33;	author momjian;	state Exp;
branches;
next	1.25;

1.25
date	2003.09.27.00.10.31;	author momjian;	state Exp;
branches;
next	1.24;

1.24
date	2003.09.12.00.12.47;	author tgl;	state Exp;
branches;
next	1.23;

1.23
date	2003.08.31.17.32.22;	author petere;	state Exp;
branches;
next	1.22;

1.22
date	2003.04.22.10.08.08;	author petere;	state Exp;
branches
	1.22.2.1;
next	1.21;

1.21
date	2002.11.21.23.34.43;	author petere;	state Exp;
branches;
next	1.20;

1.20
date	2002.09.21.18.32.54;	author petere;	state Exp;
branches
	1.20.2.1;
next	1.19;

1.19
date	2002.09.02.20.04.39;	author tgl;	state Exp;
branches;
next	1.18;

1.18
date	2002.05.18.15.44.47;	author petere;	state Exp;
branches;
next	1.17;

1.17
date	2002.04.23.02.07.16;	author tgl;	state Exp;
branches;
next	1.16;

1.16
date	2002.04.21.19.02.39;	author thomas;	state Exp;
branches;
next	1.15;

1.15
date	2002.03.06.06.48.03;	author momjian;	state Exp;
branches;
next	1.14;

1.14
date	2001.12.08.03.24.35;	author thomas;	state Exp;
branches;
next	1.13;

1.13
date	2001.11.06.23.54.32;	author tgl;	state Exp;
branches;
next	1.12;

1.12
date	2001.09.03.12.57.49;	author petere;	state Exp;
branches;
next	1.11;

1.11
date	2001.08.10.23.49.20;	author tgl;	state Exp;
branches;
next	1.10;

1.10
date	2001.01.13.23.58.55;	author petere;	state Exp;
branches;
next	1.9;

1.9
date	2000.03.27.17.14.42;	author thomas;	state Exp;
branches;
next	1.8;

1.8
date	2000.03.26.18.32.27;	author petere;	state Exp;
branches;
next	1.7;

1.7
date	99.07.22.15.09.08;	author thomas;	state Exp;
branches;
next	1.6;

1.6
date	99.07.06.17.16.36;	author thomas;	state Exp;
branches;
next	1.5;

1.5
date	98.12.29.02.24.38;	author thomas;	state Exp;
branches;
next	1.4;

1.4
date	98.10.30.19.33.55;	author thomas;	state Exp;
branches;
next	1.3;

1.3
date	98.09.22.15.47.46;	author thomas;	state Exp;
branches;
next	1.2;

1.2
date	98.09.07.15.58.23;	author thomas;	state Exp;
branches;
next	1.1;

1.1
date	98.09.01.15.53.07;	author thomas;	state Exp;
branches;
next	;

1.20.2.1
date	2002.11.21.23.31.58;	author petere;	state Exp;
branches;
next	;

1.22.2.1
date	2003.09.07.04.36.45;	author momjian;	state Exp;
branches;
next	;

1.31.2.1
date	2009.10.02.18.13.32;	author tgl;	state Exp;
branches;
next	;

1.33.2.1
date	2009.10.02.18.13.26;	author tgl;	state Exp;
branches;
next	;

1.36.2.1
date	2009.10.02.18.13.19;	author tgl;	state Exp;
branches;
next	;

1.41.2.1
date	2009.10.02.18.13.10;	author tgl;	state Exp;
branches;
next	;


desc
@@


1.43
log
@Remove unnecessary xref endterm attributes and title ids

The endterm attribute is mainly useful when the toolchain does not support
automatic link target text generation for a particular situation.  In  the
past, this was required by the man page tools for all reference page links,
but that is no longer the case, and it now actually gets in the way of
proper automatic link text generation.  The only remaining use cases are
currently xrefs to refsects.
@
text
@<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.42 2009/10/02 18:13:04 tgl Exp $
PostgreSQL documentation
-->

<refentry id="SQL-CREATEVIEW">
 <refmeta>
  <refentrytitle>CREATE VIEW</refentrytitle>
  <manvolnum>7</manvolnum>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>CREATE VIEW</refname>
  <refpurpose>define a new view</refpurpose>
 </refnamediv>

 <indexterm zone="sql-createview">
  <primary>CREATE VIEW</primary>
 </indexterm>

 <refsynopsisdiv>
<synopsis>
CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] VIEW <replaceable class="PARAMETER">name</replaceable> [ ( <replaceable class="PARAMETER">column_name</replaceable> [, ...] ) ]
    AS <replaceable class="PARAMETER">query</replaceable>
</synopsis>
 </refsynopsisdiv>

 <refsect1>
  <title>Description</title>

  <para>
   <command>CREATE VIEW</command> defines a view of a query.  The view
   is not physically materialized. Instead, the query is run every time
   the view is referenced in a query.
  </para>

  <para>
   <command>CREATE OR REPLACE VIEW</command> is similar, but if a view
   of the same name already exists, it is replaced.  The new query must
   generate the same columns that were generated by the existing view query
   (that is, the same column names in the same order and with the same data
   types), but it may add additional columns to the end of the list.  The
   calculations giving rise to the output columns may be completely different.
  </para>

  <para>
   If a schema name is given (for example, <literal>CREATE VIEW
   myschema.myview ...</>) then the view is created in the specified
   schema.  Otherwise it is created in the current schema.  Temporary
   views exist in a special schema, so a schema name cannot be given
   when creating a temporary view. The name of the view must be
   distinct from the name of any other view, table, sequence, or index
   in the same schema.
  </para>
 </refsect1>

 <refsect1>
  <title>Parameters</title>

  <variablelist>
   <varlistentry>
    <term><literal>TEMPORARY</> or <literal>TEMP</></term>
    <listitem>
     <para>
      If specified, the view is created as a temporary view.
      Temporary views are automatically dropped at the end of the
      current session.  Existing
      permanent relations with the same name are not visible to the
      current session while the temporary view exists, unless they are
      referenced with schema-qualified names.
     </para>

     <para>
      If any of the tables referenced by the view are temporary,
      the view is created as a temporary view (whether
      <literal>TEMPORARY</literal> is specified or not).
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">name</replaceable></term>
    <listitem>
     <para>
      The name (optionally schema-qualified) of a view to be created.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">column_name</replaceable></term>
    <listitem>
     <para>
      An optional list of names to be used for columns of the view.
      If not given, the column names are deduced from the query.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="parameter">query</replaceable></term>
    <listitem>
     <para>
      A <xref linkend="sql-select"> or
      <xref linkend="sql-values"> command
      which will provide the columns and rows of the view.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1>
  <title>Notes</title>

   <para>
    Currently, views are read only: the system will not allow an insert,
    update, or delete on a view.  You can get the effect of an updatable
    view by creating rules that rewrite inserts, etc. on the view into
    appropriate actions on other tables.  For more information see
    <xref linkend="sql-createrule">.
   </para>

   <para>
    Use the <xref linkend="sql-dropview">
    statement to drop views.
   </para>

   <para>
    Be careful that the names and types of the view's columns will be
    assigned the way you want.  For example:
<programlisting>
CREATE VIEW vista AS SELECT 'Hello World';
</programlisting>
    is bad form in two ways: the column name defaults to <literal>?column?</>,
    and the column data type defaults to <type>unknown</>.  If you want a
    string literal in a view's result, use something like:
<programlisting>
CREATE VIEW vista AS SELECT text 'Hello World' AS hello;
</programlisting>
   </para>

   <para>
    Access to tables referenced in the view is determined by permissions of
    the view owner.  However, functions called in the view are treated the
    same as if they had been called directly from the query using the view.
    Therefore the user of a view must have permissions to call all functions
    used by the view.
   </para>

   <para>
    When <command>CREATE OR REPLACE VIEW</> is used on an
    existing view, only the view's defining SELECT rule is changed.
    Other view properties, including ownership, permissions, and non-SELECT
    rules, remain unchanged.  You must own the view
    to replace it (this includes being a member of the owning role).
   </para>

 </refsect1>

 <refsect1>
  <title>Examples</title>

  <para>
   Create a view consisting of all comedy films:

<programlisting>
CREATE VIEW comedies AS
    SELECT *
    FROM films
    WHERE kind = 'Comedy';
</programlisting>
  </para>
 </refsect1>

 <refsect1>
  <title>Compatibility</title>

  <para>
   The SQL standard specifies some additional capabilities for the
   <command>CREATE VIEW</command> statement:
<synopsis>
CREATE VIEW <replaceable class="parameter">name</replaceable> [ ( <replaceable class="parameter">column_name</replaceable> [, ...] ) ]
    AS <replaceable class="PARAMETER">query</replaceable>
    [ WITH [ CASCADED | LOCAL ] CHECK OPTION ]
</synopsis>
  </para>

  <para>
   The optional clauses for the full SQL command are:

   <variablelist>
     <varlistentry>
      <term><literal>CHECK OPTION</literal></term>
      <listitem>
       <para>
        This option has to do with updatable views.  All
        <command>INSERT</> and <command>UPDATE</> commands on the view
        will be checked to ensure data satisfy the view-defining
        condition (that is, the new data would be visible through the
        view). If they do not, the update will be rejected.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><literal>LOCAL</literal></term>
      <listitem>
       <para>
        Check for integrity on this view.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><literal>CASCADED</literal></term>
      <listitem>
       <para>
        Check for integrity on this view and on any dependent
        view. <literal>CASCADED</> is assumed if neither
        <literal>CASCADED</> nor <literal>LOCAL</> is specified.
       </para>
      </listitem>
     </varlistentry>
   </variablelist>
  </para>

  <para>
   <command>CREATE OR REPLACE VIEW</command> is a
   <productname>PostgreSQL</productname> language extension.
   So is the concept of a temporary view.
  </para>
 </refsect1>

 <refsect1>
  <title>See Also</title>

  <simplelist type="inline">
   <member><xref linkend="sql-alterview"></member>
   <member><xref linkend="sql-dropview"></member>
  </simplelist>
 </refsect1>
</refentry>
@


1.42
log
@Fix erroneous handling of shared dependencies (ie dependencies on roles)
in CREATE OR REPLACE FUNCTION.  The original code would update pg_shdepend
as if a new function was being created, even if it wasn't, with two bad
consequences: pg_shdepend might record the wrong owner for the function,
and any dependencies for roles mentioned in the function's ACL would be lost.
The fix is very easy: just don't touch pg_shdepend at all when doing a
function replacement.

Also update the CREATE FUNCTION reference page, which never explained
exactly what changes and doesn't change in a function replacement.
In passing, fix the CREATE VIEW reference page similarly; there's no
code bug there, but the docs didn't say what happens.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.41 2009/01/27 12:40:15 petere Exp $
d8 1
a8 1
  <refentrytitle id="SQL-CREATEVIEW-TITLE">CREATE VIEW</refentrytitle>
d105 2
a106 2
      A <xref linkend="sql-select" endterm="sql-select-title"> or
      <xref linkend="sql-values" endterm="sql-values-title"> command
d122 1
a122 1
    <xref linkend="sql-createrule" endterm="sql-createrule-title">.
d126 1
a126 1
    Use the <xref linkend="sql-dropview" endterm="sql-dropview-title">
d240 2
a241 2
   <member><xref linkend="sql-alterview" endterm="sql-alterview-title"></member>
   <member><xref linkend="sql-dropview" endterm="sql-dropview-title"></member>
@


1.41
log
@Revert updatable views
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.40 2009/01/22 17:27:54 petere Exp $
d152 8
@


1.41.2.1
log
@Fix erroneous handling of shared dependencies (ie dependencies on roles)
in CREATE OR REPLACE FUNCTION.  The original code would update pg_shdepend
as if a new function was being created, even if it wasn't, with two bad
consequences: pg_shdepend might record the wrong owner for the function,
and any dependencies for roles mentioned in the function's ACL would be lost.
The fix is very easy: just don't touch pg_shdepend at all when doing a
function replacement.

Also update the CREATE FUNCTION reference page, which never explained
exactly what changes and doesn't change in a function replacement.
In passing, fix the CREATE VIEW reference page similarly; there's no
code bug there, but the docs didn't say what happens.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.41 2009/01/27 12:40:15 petere Exp $
a151 8
   <para>
    When <command>CREATE OR REPLACE VIEW</> is used on an
    existing view, only the view's defining SELECT rule is changed.
    Other view properties, including ownership, permissions, and non-SELECT
    rules, remain unchanged.  You must own the view
    to replace it (this includes being a member of the owning role).
   </para>

@


1.40
log
@Automatic view update rules

Bernd Helmle
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.39 2008/12/15 21:35:31 tgl Exp $
d118 5
a122 93
    Some views are updatable, which means that the
    commands <command>INSERT</command>, <command>UPDATE</command>,
    and <command>DELETE</command> can be used on the view as if it
    were a regular table.  A view is updatable if it
    does <emphasis>not</emphasis> contain:

    <itemizedlist>
     <listitem>
      <para>
       more than one underlying table (joins) or no underlying table at all
      </para>
     </listitem>

     <listitem>
      <para>
       underlying tables/views that are themselves not updatable,
       including table value constructors and table functions
      </para>
     </listitem>

     <listitem>
      <para>
       subqueries in the <literal>FROM</literal> list
      </para>
     </listitem>

     <listitem>
      <para>
       items in the select list that are not direct references to a
       column of the underlying table, such as literals or any
       nontrivial value expression
      </para>
     </listitem>

     <listitem>
      <para>
       references to system columns in the select list
      </para>
     </listitem>

     <listitem>
      <para>
       more than one reference to the same column in the select list
      </para>
     </listitem>

     <listitem>
      <para>aggregate function calls</para>
     </listitem>

     <listitem>
      <para>window function calls</para>
     </listitem>

     <listitem>
      <para>
       <literal>WITH</literal> or <literal>WITH RECURSIVE</literal> clauses
      </para>
     </listitem>

     <listitem>
      <para>
       <literal>DISTINCT</literal>, <literal>GROUP BY</literal>, or
       <literal>HAVING</literal> clauses
      </para>
     </listitem>

     <listitem>
      <para>
       <literal>UNION</literal>, <literal>INTERSECT</literal>, or
       <literal>EXCEPT</literal> clauses
      </para>
     </listitem>

     <listitem>
      <para>
       <literal>LIMIT</literal> or <literal>OFFSET</literal> clauses
       (or other equivalent spellings thereof)
      </para>
     </listitem>
    </itemizedlist>
   </para>

   <para>
    The updatable views implementation is based on the rule system.
    Because of this, you can also make more complex views updatable or
    insertable by creating your own rules that rewrite
    the <command>INSERT</command>,
    <command>UPDATE</command>, and <command>DELETE</command> actions
    on the view into appropriate actions on other tables.  You can
    also replace the automatically generated rules by your own rules.
    For more information on the rule system, refer
    to <xref linkend="sql-createrule" endterm="sql-createrule-title">.
@


1.39
log
@Code review for CREATE OR REPLACE VIEW patch.  Do things in a saner order to
result in hopefully-less-confusing error messages when the new definition
isn't compatible with the old; minor other cleanup.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.38 2008/12/06 23:22:46 momjian Exp $
d118 93
a210 5
    Currently, views are read only: the system will not allow an insert,
    update, or delete on a view.  You can get the effect of an updatable
    view by creating rules that rewrite inserts, etc. on the view into
    appropriate actions on other tables.  For more information see
    <xref linkend="sql-createrule" endterm="sql-createrule-title">.
@


1.38
log
@Allow CREATE OR REPLACE VIEW to add columns to the _end_ of the view.

Robert Haas
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.37 2008/11/14 10:22:46 petere Exp $
d41 4
a44 3
   generate all of the same columns that were generated by the original query
   in the same order and with the same data types, but may add additional
   columns to the end of the list.
d81 1
a81 1
   
d168 1
a168 1
 
@


1.37
log
@Set SQL man pages to be section 7 by default, and only transform them to
another section if required by the platform (instead of the old way of
building them in section "l" and always transforming them to the
platform-specific section).

This speeds up the installation on common platforms, and it avoids some
funny business with the man page tools and build process.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.36 2007/07/03 01:30:35 neilc Exp $
d40 4
a43 3
   of the same name already exists, it is replaced.  You can only replace
   a view with a new query that generates the identical set of columns
   (i.e., same column names and data types).
@


1.36
log
@Add ALTER VIEW ... RENAME TO, and a RENAME TO clause to ALTER SEQUENCE.
Sequences and views could previously be renamed using ALTER TABLE, but
this was a repeated source of confusion for users. Update the docs,
and psql tab completion. Patch from David Fetter; various minor fixes
by myself.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.35 2007/02/01 00:28:18 momjian Exp $
d9 1
@


1.36.2.1
log
@Fix erroneous handling of shared dependencies (ie dependencies on roles)
in CREATE OR REPLACE FUNCTION.  The original code would update pg_shdepend
as if a new function was being created, even if it wasn't, with two bad
consequences: pg_shdepend might record the wrong owner for the function,
and any dependencies for roles mentioned in the function's ACL would be lost.
The fix is very easy: just don't touch pg_shdepend at all when doing a
function replacement.

Also update the CREATE FUNCTION reference page, which never explained
exactly what changes and doesn't change in a function replacement.
In passing, fix the CREATE VIEW reference page similarly; there's no
code bug there, but the docs didn't say what happens.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.36 2007/07/03 01:30:35 neilc Exp $
a148 8
   <para>
    When <command>CREATE OR REPLACE VIEW</> is used on an
    existing view, only the view's defining SELECT rule is changed.
    Other view properties, including ownership, permissions, and non-SELECT
    rules, remain unchanged.  You must own the view
    to replace it (this includes being a member of the owning role).
   </para>

@


1.35
log
@Consistenly use colons before '<programlisting>' blocks, where
appropriate.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.34 2007/01/31 23:26:03 momjian Exp $
d229 1
@


1.34
log
@Update reference documentation on may/can/might:

Standard English uses "may", "can", and "might" in different ways:

        may - permission, "You may borrow my rake."

        can - ability, "I can lift that log."

        might - possibility, "It might rain today."

Unfortunately, in conversational English, their use is often mixed, as
in, "You may use this variable to do X", when in fact, "can" is a better
choice.  Similarly, "It may crash" is better stated, "It might crash".
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.33 2006/09/18 19:54:01 tgl Exp $
d129 1
a129 1
    assigned the way you want.  For example,
d135 1
a135 1
    string literal in a view's result, use something like
@


1.33
log
@Documentation for VALUES lists.  Joe Conway and Tom Lane
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.32 2006/09/16 00:30:17 momjian Exp $
d48 1
a48 1
   views exist in a special schema, so a schema name may not be given
@


1.33.2.1
log
@Fix erroneous handling of shared dependencies (ie dependencies on roles)
in CREATE OR REPLACE FUNCTION.  The original code would update pg_shdepend
as if a new function was being created, even if it wasn't, with two bad
consequences: pg_shdepend might record the wrong owner for the function,
and any dependencies for roles mentioned in the function's ACL would be lost.
The fix is very easy: just don't touch pg_shdepend at all when doing a
function replacement.

Also update the CREATE FUNCTION reference page, which never explained
exactly what changes and doesn't change in a function replacement.
In passing, fix the CREATE VIEW reference page similarly; there's no
code bug there, but the docs didn't say what happens.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.33 2006/09/18 19:54:01 tgl Exp $
a148 8
   <para>
    When <command>CREATE OR REPLACE VIEW</> is used on an
    existing view, only the view's defining SELECT rule is changed.
    Other view properties, including ownership, permissions, and non-SELECT
    rules, remain unchanged.  You must own the view
    to replace it (this includes being a member of the owning role).
   </para>

@


1.32
log
@Remove emacs info from footer of SGML files.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.31 2005/11/01 21:09:50 tgl Exp $
d102 3
a104 7
      A query (that is, a <command>SELECT</> statement) which will
      provide the columns and rows of the view.
     </para>

     <para>
      Refer to <xref linkend="sql-select" endterm="sql-select-title">
      for more information about valid queries.
@


1.31
log
@Make an editorial pass over the reference pages.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.30 2005/02/02 06:35:59 neilc Exp $
a236 17

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->
@


1.31.2.1
log
@Fix erroneous handling of shared dependencies (ie dependencies on roles)
in CREATE OR REPLACE FUNCTION.  The original code would update pg_shdepend
as if a new function was being created, even if it wasn't, with two bad
consequences: pg_shdepend might record the wrong owner for the function,
and any dependencies for roles mentioned in the function's ACL would be lost.
The fix is very easy: just don't touch pg_shdepend at all when doing a
function replacement.

Also update the CREATE FUNCTION reference page, which never explained
exactly what changes and doesn't change in a function replacement.
In passing, fix the CREATE VIEW reference page similarly; there's no
code bug there, but the docs didn't say what happens.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.31 2005/11/01 21:09:50 tgl Exp $
a152 8
   <para>
    When <command>CREATE OR REPLACE VIEW</> is used on an
    existing view, only the view's defining SELECT rule is changed.
    Other view properties, including ownership, permissions, and non-SELECT
    rules, remain unchanged.  You must own the view
    to replace it (this includes being a member of the owning role).
   </para>

@


1.30
log
@Add support for temporary views, including documentation and regression
tests. Contributed by Koju Iijima, review from Neil Conway, Gavin Sherry
and Tom Lane.

Also, fix error in description of WITH CHECK OPTION clause in the CREATE
VIEW reference page: it should be "CASCADED", not "CASCADE".
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.29 2005/01/04 00:39:53 tgl Exp $
d23 2
a24 2
CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] VIEW <replaceable class="PARAMETER">name</replaceable> [ ( <replaceable
class="PARAMETER">column_name</replaceable> [, ...] ) ] AS <replaceable class="PARAMETER">query</replaceable>
d65 1
a65 3
      current session. Temporary views are automatically placed in the
      current backend's local temporary schema, so it is illegal to
      specify a schema-qualified name for a temporary view. Existing
d72 1
a72 1
      If any of the base tables referenced by the view are temporary,
d177 2
a178 2
CREATE VIEW <replaceable class="parameter">name</replaceable> [ ( <replaceable class="parameter">column</replaceable> [, ...] ) ]
    AS query
d225 1
@


1.29
log
@More minor updates and copy-editing.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.28 2003/11/29 19:51:38 pgsql Exp $
d23 1
a23 1
CREATE [ OR REPLACE ] VIEW <replaceable class="PARAMETER">name</replaceable> [ ( <replaceable
d46 6
a51 4
   myschema.myview ...</>) then the view is created in the
   specified schema.  Otherwise it is created in the current schema.
   The view name must be distinct from the name of any other view, table,
   sequence, or index in the same schema.
d60 22
d129 2
a130 1
    Use the <command>DROP VIEW</command> statement to drop views.
d181 1
a181 1
    [ WITH [ CASCADE | LOCAL ] CHECK OPTION ]
d212 1
a212 1
      <term><literal>CASCADE</literal></term>
d216 2
a217 2
        view. <literal>CASCADE</> is assumed if neither
        <literal>CASCADE</> nor <literal>LOCAL</> is specified.
@


1.28
log
@
$Header: -> $PostgreSQL Changes ...
@
text
@d2 1
a2 1
$PostgreSQL: /cvsroot/pgsql-server/doc/src/sgml/ref/create_view.sgml,v 1.27 2003/11/01 01:56:29 petere Exp $
d168 1
a168 1
        This option is to do with updatable views.  All
d204 8
@


1.27
log
@Spell checking, consistent terminology.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_view.sgml,v 1.26 2003/09/28 01:19:33 momjian Exp $
@


1.26
log
@Update docs on function call permissions in view, from Tom.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_view.sgml,v 1.25 2003/09/27 00:10:31 momjian Exp $
d33 1
a33 1
   is not physically materialized. Instead, the query is run everytime
d115 1
a115 1
    and the column datatype defaults to <type>unknown</>.  If you want a
@


1.25
log
@Document that functions are checked independently of the view
permissions.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_view.sgml,v 1.24 2003/09/12 00:12:47 tgl Exp $
d123 5
a127 2
    While access to tables in the view is controlled entirely by permissions
    on the view, functions called by the view are checked independently.
@


1.24
log
@More cleanup of Diagnostics sections.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_view.sgml,v 1.23 2003/08/31 17:32:22 petere Exp $
d121 6
@


1.23
log
@Add/edit index entries.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_view.sgml,v 1.22 2003/04/22 10:08:08 petere Exp $
a93 33
  <title>Diagnostics</title>

  <variablelist>
   <varlistentry>
    <term><computeroutput>CREATE VIEW</computeroutput></term>
    <listitem>
     <para>
      Message returned if the view was successfully created.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><computeroutput>WARNING:  Attribute '<replaceable class="parameter">column</replaceable>' has an unknown type</computeroutput></term>
    <listitem>
     <para>
      The view will be created having a column with an unknown type if
      you do not specify it. For example, the following command gives
      this warning:
<programlisting>
CREATE VIEW vista AS SELECT 'Hello World'
</programlisting>
      whereas this command does not:
<programlisting>
CREATE VIEW vista AS SELECT text 'Hello World'
</programlisting>
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1>
d106 14
@


1.22
log
@More editing of reference pages.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_view.sgml,v 1.21 2002/11/21 23:34:43 petere Exp $
d16 4
@


1.22.2.1
log
@Update this branch to match CVS head, includes WIN32 improvements.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_view.sgml,v 1.23 2003/08/31 17:32:22 petere Exp $
a15 4

 <indexterm zone="sql-createview">
  <primary>CREATE VIEW</primary>
 </indexterm>
@


1.21
log
@Fixups for man pages
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_view.sgml,v 1.20 2002/09/21 18:32:54 petere Exp $
d11 1
d13 2
a14 6
  <refname>
   CREATE VIEW
  </refname>
  <refpurpose>
   define a new view
  </refpurpose>
d16 1
d18 4
a21 106
  <refsynopsisdivinfo>
   <date>2000-03-25</date>
  </refsynopsisdivinfo>
  <synopsis>
CREATE [ OR REPLACE ] VIEW <replaceable class="PARAMETER">view</replaceable> [ ( <replaceable
class="PARAMETER">column name list</replaceable> ) ] AS SELECT <replaceable class="PARAMETER">query</replaceable>
  </synopsis>

  <refsect2 id="R2-SQL-CREATEVIEW-1">
   <refsect2info> 
    <date>2000-03-25</date>
   </refsect2info>
   <title>
    Inputs
   </title>
   <para>

    <variablelist>
     <varlistentry>
      <term><replaceable class="parameter">view</replaceable></term>
      <listitem>
       <para>
	The name (optionally schema-qualified) of a view to be created.
       </para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><replaceable class="parameter">column name list</replaceable></term>
      <listitem>
       <para>
        An optional list of names to be used for columns of the view.
	If given, these names override the column names that would be
	deduced from the SQL query.
       </para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><replaceable class="parameter">query</replaceable></term>
      <listitem>
       <para>
	An SQL query (that is, a <command>SELECT</> statement)
	which will provide the columns and rows of the view.
       </para>
       <para>
	Refer to <xref linkend="sql-select" endterm="sql-select-title"> for more information
	about valid arguments.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
  </refsect2>

  <refsect2 id="R2-SQL-CREATEVIEW-2">
   <refsect2info>
    <date>2000-03-25</date>
   </refsect2info>
   <title>
    Outputs
   </title>
   <para>
    <variablelist>
     <varlistentry>
      <term><computeroutput>
CREATE VIEW
       </computeroutput></term>
      <listitem>
       <para>
	The message returned if the view is successfully created.
       </para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><computeroutput>
ERROR:  Relation '<replaceable class="parameter">view</replaceable>' already exists
       </computeroutput></term>
      <listitem>
       <para>
	This error occurs if the view specified already exists in the database.
       </para>
      </listitem>
     </varlistentry>
     <varlistentry>
      <term><computeroutput>
WARNING:  Attribute '<replaceable class="parameter">column</replaceable>' has an unknown type
       </computeroutput></term>
      <listitem>
       <para>
	The view will be created having a column with an unknown type
	if you do not specify it. For example, the following command gives
	a warning:
	<programlisting>
CREATE VIEW vista AS SELECT 'Hello World'
	</programlisting>

	whereas this command does not:

	<programlisting>
CREATE VIEW vista AS SELECT text 'Hello World'
	</programlisting>
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
  </refsect2>
d24 2
a25 7
 <refsect1 id="R1-SQL-CREATEVIEW-1">
  <refsect1info>
   <date>2000-03-25</date>
  </refsect1info>
  <title>
   Description
  </title>
d28 3
a30 4
   <command>CREATE VIEW</command> defines a view of a query.
   The view is not physically materialized. Instead, a query
   rewrite rule (an <literal>ON SELECT</> rule) is automatically generated to
   support SELECT operations on views.
d43 1
a43 2
   specified schema.  Otherwise it is created in the current schema (the one
   at the front of the search path; see <literal>CURRENT_SCHEMA()</>).
d47 1
d49 75
a123 7
  <refsect2 id="R2-SQL-CREATEVIEW-3">
   <refsect2info>
    <date>2000-03-25</date>
   </refsect2info>
   <title>
    Notes
   </title>
a135 1
  </refsect2>
d138 3
a140 4
 <refsect1 id="R1-SQL-CREATEVIEW-2">
  <title>
   Usage
  </title>
d142 1
a142 1
   Create a view consisting of all Comedy films:
d144 2
a145 2
   <programlisting>
CREATE VIEW kinds AS
d149 1
a149 9

SELECT * FROM kinds;

 code  |           title           | did | date_prod  |  kind  | len
-------+---------------------------+-----+------------+--------+-------
 UA502 | Bananas                   | 105 | 1971-07-13 | Comedy | 01:22
 C_701 | There's a Girl in my Soup | 107 | 1970-06-11 | Comedy | 01:36
(2 rows)
   </programlisting>
d153 2
a154 12
 <refsect1 id="R1-SQL-CREATEVIEW-3">
  <title>
   Compatibility
  </title>
  
  <refsect2 id="R2-SQL-CREATEVIEW-5">
   <refsect2info>
    <date>2000-03-25</date>
   </refsect2info>
   <title>
    SQL92
   </title>
d156 6
a161 8
   <para>
    SQL92 specifies some additional capabilities for the
    <command>CREATE VIEW</command> statement:
   </para>
   <synopsis>
CREATE VIEW <replaceable class="parameter">view</replaceable> [ <replaceable class="parameter">column</replaceable> [, ...] ]
    AS SELECT <replaceable class="parameter">expression</replaceable> [ AS <replaceable class="parameter">colname</replaceable> ] [, ...]
    FROM <replaceable class="parameter">table</replaceable> [ WHERE <replaceable class="parameter">condition</replaceable> ]
d163 2
a164 1
   </synopsis>
d166 2
a167 2
   <para>
    The optional clauses for the full SQL92 command are:
d171 1
a171 1
      <term>CHECK OPTION</term>
d174 5
a178 4
	This option is to do with updatable views.
	All <command>INSERT</> and <command>UPDATE</> commands on the view will be
	checked to ensure data satisfy the view-defining
	condition. If they do not, the update will be rejected.
d184 1
a184 1
      <term>LOCAL</term>
d187 1
a187 1
	Check for integrity on this view.
d193 1
a193 1
      <term>CASCADE</term>
d196 3
a198 2
	Check for integrity on this view and on any dependent
	view. CASCADE is assumed if neither CASCADE nor LOCAL is specified.
d202 2
a203 2
    </variablelist>
   </para>
d205 4
a208 6
   <para>
    <command>CREATE OR REPLACE VIEW</command> is a
    <productname>PostgreSQL</productname> language extension.
   </para>

  </refsect2>
@


1.20
log
@Add more appropriate markup.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_view.sgml,v 1.19 2002/09/02 20:04:39 tgl Exp $
d64 1
a64 1
	Refer to <xref linkend="sql-select"> for more information
d172 1
a172 1
    <xref linkend="sql-createrule">.
@


1.20.2.1
log
@Fixups for man pages
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_view.sgml,v 1.20 2002/09/21 18:32:54 petere Exp $
d64 1
a64 1
	Refer to <xref linkend="sql-select" endterm="sql-select-title"> for more information
d172 1
a172 1
    <xref linkend="sql-createrule" endterm="sql-createrule-title">.
@


1.19
log
@Department of second thoughts: make checks for replacing a view slightly
more flexible, and improve the error reporting.  Also, add documentation
for REPLACE RULE/VIEW.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_view.sgml,v 1.18 2002/05/18 15:44:47 petere Exp $
d238 1
a238 1
	All INSERTs and UPDATEs on the view will be
@


1.18
log
@Revise command completion tags as per hackers message on 20 March.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.17 2002/04/23 02:07:16 tgl Exp $
d24 1
a24 1
CREATE VIEW <replaceable class="PARAMETER">view</replaceable> [ ( <replaceable
d135 1
d137 1
a137 1
   <command>CREATE VIEW</command> will define a view of a query.
d144 7
d217 1
d265 6
@


1.17
log
@Update SQL-command reference pages for schema features.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.16 2002/04/21 19:02:39 thomas Exp $
d84 1
a84 1
CREATE
@


1.16
log
@Augment the date/time examples in the User's Guide to reflect the newer
 capabilities of specifying time zones as intervals per SQL9x.
Put refentrytitle contents on the same line as the tag.
 Otherwise, leading whitespace is propagated into the product, which
 (at least) messes up the ToC layout.
Remove (some) docinfo tags containing dates. Best to omit if the dates
 are not accurate; maybe use CVS dates instead or leave them out.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.15 2002/03/06 06:48:03 momjian Exp $
d42 1
a42 1
	The name of a view to be created.
d60 2
a61 1
	An SQL query which will provide the columns and rows of the view.
d64 1
a64 1
	Refer to the SELECT statement for more information
d136 1
a136 1
   <command>CREATE VIEW</command> will define a view of a table.
d138 11
a148 2
   rewrite retrieve rule is automatically generated to support
   retrieve operations on views.
@


1.15
log
@Update reference pages for new INFO, NOTICE, WARNING elog() levels.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.14 2001/12/08 03:24:35 thomas Exp $
d8 1
a8 3
  <refentrytitle id="SQL-CREATEVIEW-TITLE">
   CREATE VIEW
  </refentrytitle>
@


1.14
log
@Use PostgreSQL consistantly throughout docs. Before, usage was split evenly
 between Postgres and PostgreSQL.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.13 2001/11/06 23:54:32 tgl Exp $
d105 1
a105 1
NOTICE:  Attribute '<replaceable class="parameter">column</replaceable>' has an unknown type
@


1.13
log
@Add some notes about conditional rules used with views.
@
text
@d2 2
a3 2
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.12 2001/09/03 12:57:49 petere Exp $
Postgres documentation
@


1.12
log
@Put some kind of grammatical uniformity in the <refpurpose> lines.
@
text
@d2 1
a2 1
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.11 2001/08/10 23:49:20 tgl Exp $
d105 1
a105 1
NOTICE create: attribute named "<replaceable class="parameter">column</replaceable>" has an unknown type
d152 5
a156 1
    Currently, views are read only.
@


1.11
log
@Document column-name-list option of CREATE VIEW ... which has been there
awhile, but the man page didn't know it.
@
text
@d2 1
a2 1
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.10 2001/01/13 23:58:55 petere Exp $
d18 1
a18 1
   Constructs a virtual table
@


1.10
log
@Terminology cleanup: class -> table, instance -> row, attribute -> column,
etc.
@
text
@d2 1
a2 1
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.9 2000/03/27 17:14:42 thomas Exp $
d26 2
a27 1
CREATE VIEW <replaceable class="PARAMETER">view</replaceable> AS SELECT <replaceable class="PARAMETER">query</replaceable>
d49 10
d138 1
a138 1
   This view is not physically materialized. Specifically, a query
@


1.9
log
@Start updating for the v7.0 release.
Use "generic functions" for math and other routines.
Use SQL92 "type 'literal'" syntax rather than Postgres "'literal'::type".
@
text
@d2 1
a2 1
$Header: /usr/local/cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.8 2000/03/26 18:32:27 petere Exp $
d126 2
a127 2
   <command>CREATE VIEW</command> will define a view of a table or
   class. This view is not physically materialized. Specifically, a query
@


1.8
log
@Updated user's guide to match new psql's output format
Fixed bug in createdb/alternative location
@
text
@d2 1
a2 1
$Header: /usr/local/cvsroot/pgsql/doc/src/sgml/ref/create_view.sgml,v 1.7 1999/07/22 15:09:08 thomas Exp $
d23 1
a23 1
   <date>1999-07-20</date>
d30 2
a31 2
   <refsect2info>
    <date>1998-09-21</date>
d65 1
a65 1
    <date>1998-09-21</date>
d100 1
a100 1
	an error:
d104 1
d106 1
d108 1
a108 1
CREATE VIEW vista AS SELECT 'Hello World'::text
d120 1
a120 1
   <date>1998-09-21</date>
d134 1
a134 1
    <date>1998-09-21</date>
d181 1
a181 1
    <date>1998-09-21</date>
@


1.7
log
@Complete merge of all old man page information.
ecpg reference page still needs formatting.
@
text
@d2 1
a2 1
$Header$
d163 5
a167 4
code |title                    |did| date_prod|kind      |len
-----+-------------------------+---+----------+----------+------
UA502|Bananas                  |105|1971-07-13|Comedy    | 01:22
C_701|There's a Girl in my Soup|107|1970-06-11|Comedy    | 01:36
@


1.6
log
@Fix markup for docbook2man man page generation.
No big deal; fixed lots of other markup at the same time.
Bigest change: make sure there is no whitespace
 in front of <term> contents.
This will probably help the other output types too.
@
text
@d1 5
d8 1
a8 1
  <refentrytitle>
d23 1
a23 1
   <date>1998-09-21</date>
d26 1
a26 2
CREATE VIEW <replaceable class="PARAMETER">view</replaceable>
    AS SELECT <replaceable class="PARAMETER">query</replaceable>
d37 1
d124 4
a127 4
   <command>CREATE VIEW</command> will define a view of a table. This view is
   not physically materialized. Specifically, a query
   rewrite retrieve rule is automatically generated
   to support retrieve operations on views.
d137 1
d139 1
a139 1
    Use the <command>DROP VIEW</command> statement to drop views.
a140 1
  </refsect2>
a141 7
  <refsect2 id="R2-SQL-CREATEVIEW-4">
   <refsect2info>
    <date>1998-09-21</date>
   </refsect2info>
   <title>
    Bugs
   </title>
d143 1
a143 1
    Currently, views are read only.
a174 2
  <para>
  </para>
d209 1
d218 1
@


1.5
log
@Clean up to ensure tag completion as required by the newest versions
 of Norm's Modular Style Sheets and jade/docbook.
From Vince Vielhaber <vev@@michvhf.com>.
@
text
@d1 3
a3 3
<REFENTRY ID="SQL-CREATEVIEW">
 <REFMETA>
  <REFENTRYTITLE>
d5 5
a9 5
  </REFENTRYTITLE>
  <REFMISCINFO>SQL - Language Statements</REFMISCINFO>
 </REFMETA>
 <REFNAMEDIV>
  <REFNAME>
d11 4
a14 4
  </REFNAME>
  <REFPURPOSE>
Constructs a virtual table
  </REFPURPOSE>
d16 14
a29 14
 <REFSYNOPSISDIV>
  <REFSYNOPSISDIVINFO>
   <DATE>1998-09-21</DATE>
  </REFSYNOPSISDIVINFO>
  <SYNOPSIS>
CREATE VIEW <REPLACEABLE CLASS="PARAMETER">view</REPLACEABLE>
    AS SELECT <REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE>
  </SYNOPSIS>
  
  <REFSECT2 ID="R2-SQL-CREATEVIEW-1">
   <REFSECT2INFO>
    <DATE>1998-09-21</DATE>
   </REFSECT2INFO>
   <TITLE>
d31 24
a54 28
   </TITLE>
   <PARA>
       <VARIABLELIST>
	<VARLISTENTRY>
	 <TERM>
	  <ReturnValue><replaceable class="parameter">view</replaceable></ReturnValue>
	 </TERM>
	 <LISTITEM>
	  <PARA>
          The name of a view to be created.
	  </PARA>
	 </LISTITEM>
	</VARLISTENTRY>
	<VARLISTENTRY>
	 <TERM>
	  <ReturnValue><replaceable class="parameter">query</replaceable></ReturnValue>
	 </TERM>
	 <LISTITEM>
	  <PARA>
An SQL query which will provide the columns and rows of the view.
	  </PARA>
	  <PARA>
	   Refer to the SELECT statement for more information
	   about valid arguments.
	  </PARA>
	 </LISTITEM>
	</VARLISTENTRY>
       </variablelist>
d56 7
a62 7
  </REFSECT2>
  
  <REFSECT2 ID="R2-SQL-CREATEVIEW-2">
   <REFSECT2INFO>
    <DATE>1998-09-21</DATE>
   </REFSECT2INFO>
   <TITLE>
d64 39
a102 41
   </TITLE>
   <PARA>
       <VARIABLELIST>
	<VARLISTENTRY>
	 <TERM>
	  <ReturnValue>CREATE</ReturnValue>
	 </TERM>
	 <LISTITEM>
	  <PARA>
          The message returned if the view is successfully created.
	  </PARA>
	 </LISTITEM>
	</VARLISTENTRY>
	<VARLISTENTRY>
	 <TERM>
	  <ReturnValue>
	   WARN amcreate: "<replaceable class="parameter">view</replaceable>" relation already exists
	  </ReturnValue>
	 </TERM>
	 <LISTITEM>
	  <PARA>
          This error occurs if the view specified already exists in the database.
	  </PARA>
	 </LISTITEM>
	</VARLISTENTRY>
	<VARLISTENTRY>
	 <TERM>
	  <ReturnValue>NOTICE create: attribute named "<replaceable class="parameter">column</replaceable>" has an unknown type</ReturnValue>
	 </TERM>
	 <LISTITEM>
	  <PARA>
          The view will be created having a column with an unknown type
	   if you do not specify it. For example, the following command gives
	   an error:
	   <programlisting>
	    CREATE VIEW vista AS SELECT 'Hello World'
	   </programlisting>
	   whereas this command does not:
	   <programlisting>
	    CREATE VIEW vista AS SELECT 'Hello World'::text
	   </programlisting>
d106 1
a106 1
    </VARIABLELIST>
d108 8
a115 8
  </REFSECT2>
 </REFSYNOPSISDIV>
 
 <REFSECT1 ID="R1-SQL-CREATEVIEW-1">
  <REFSECT1INFO>
   <DATE>1998-09-21</DATE>
  </REFSECT1INFO>
  <TITLE>
d117 3
a119 3
  </TITLE>
  <PARA>
   CREATE VIEW will define a view of a table. This view is
d123 7
a129 7
  </PARA>
  
  <REFSECT2 ID="R2-SQL-CREATEVIEW-3">
   <REFSECT2INFO>
    <DATE>1998-09-21</DATE>
   </REFSECT2INFO>
   <TITLE>
d131 4
a134 4
   </TITLE>
   <PARA>
   Use the DROP VIEW statement to drop views.
   </PARA>
d136 6
a141 6
  
  <REFSECT2 ID="R2-SQL-CREATEVIEW-4">
   <REFSECT2INFO>
    <DATE>1998-09-21</DATE>
   </REFSECT2INFO>
   <TITLE>
d143 1
a143 1
   </TITLE>
d145 1
a145 1
   Currently, views are read only.
d147 1
a147 1
  </REFSECT2>
d150 2
a151 2
 <REFSECT1 ID="R1-SQL-CREATEVIEW-2">
  <TITLE>
d153 2
a154 2
  </TITLE>
  <PARA>
d156 2
a157 2
  </PARA>
  <ProgramListing>
d169 3
a171 3
  </ProgramListing>
  
 </REFSECT1>
d173 2
a174 2
 <REFSECT1 ID="R1-SQL-CREATEVIEW-3">
  <TITLE>
d176 9
a184 9
  </TITLE>
  <PARA>
  </PARA>
  
  <REFSECT2 ID="R2-SQL-CREATEVIEW-5">
   <REFSECT2INFO>
    <DATE>1998-09-21</DATE>
   </REFSECT2INFO>
   <TITLE>
d186 5
a190 4
   </TITLE>
   <PARA>
   SQL92 specifies some additional capabilities for the CREATE VIEW statement:
   </PARA>
d193 2
a194 3
    AS SELECT <replaceable class="parameter">expression</replaceable> [AS <replaceable class="parameter">colname</replaceable>] [, ...]
    FROM <replaceable class="parameter">table</replaceable>
    [ WHERE <replaceable class="parameter">condition</replaceable> ]
d198 34
a231 45
   <VARIABLELIST>
    <VARLISTENTRY>
     <TERM>
     </TERM>
     <LISTITEM>
      <PARA>
       <VARIABLELIST>
	<VARLISTENTRY>
	 <TERM>
	  CHECK OPTION
	 </TERM>
	 <LISTITEM>
	  <PARA> This option is to do with updatable views.
                     All INSERTs and UPDATEs on the view will be
                     checked to ensure data satisfy the view-defining
                     condition. If they do not, the update will be rejected.
	  </PARA>
	 </LISTITEM>
	</VARLISTENTRY>
	<VARLISTENTRY>
	 <TERM>
	  LOCAL
	 </TERM>
	 <LISTITEM>
	  <PARA>
	   Check for integrity on this view.
	  </PARA>
	 </LISTITEM>
	</VARLISTENTRY>
	<VARLISTENTRY>
	 <TERM>
	  CASCADE
	 </TERM>
	 <LISTITEM>
	  <PARA>
	   Check for integrity on this view and on any dependent
	   view. CASCADE is assumed if neither CASCADE nor LOCAL is specified.
	  </PARA>
	 </LISTITEM>
	</VARLISTENTRY>
       </variablelist>
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
d234 1
a234 2
</REFENTRY>

d239 1
a239 1
sgml-omittag:t
@


1.4
log
@Minor cleanup in markup, especially in the Output section.
@
text
@d15 1
d59 1
d109 5
a113 2

   </VARIABLELIST>
d154 2
a155 1
  
@


1.3
log
@Editing and markup cleanup.
@
text
@a67 8
   </PARA>
   <VARIABLELIST>
    <VARLISTENTRY>
     <TERM>
<replaceable>status</replaceable>
     </TERM>
     <LISTITEM>
      <PARA>
d107 1
a107 6
	  </PARA>
	 </LISTITEM>
	</VARLISTENTRY>
       </variablelist>
     </LISTITEM>
    </VARLISTENTRY>
@


1.2
log
@Very minor formatting fixup in the refentry id field to remove
 the trailing "-1". This makes a cleaner html output file name.
Clean up a few refpurpose fields.
@
text
@d17 1
a17 1
   <DATE>1998-04-15</DATE>
d20 2
a21 2
   CREATE VIEW <REPLACEABLE CLASS="PARAMETER">view</REPLACEABLE>
       AS SELECT <REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE>
d26 1
a26 1
    <DATE>1998-04-15</DATE>
a31 7
   </PARA>
   <VARIABLELIST>
    <VARLISTENTRY>
     <TERM>
     </TERM>
     <LISTITEM>
      <PARA>
a57 3
     </LISTITEM>
    </VARLISTENTRY>
   </VARIABLELIST>
d62 1
a62 1
    <DATE>1998-04-15</DATE>
d72 1
d127 1
a127 1
   <DATE>1998-04-15</DATE>
d141 1
a141 1
    <DATE>1998-04-15</DATE>
d153 1
a153 1
    <DATE>1998-04-15</DATE>
d171 4
a174 4
   CREATE VIEW kinds AS
         SELECT *
         FROM films
         WHERE kind = 'Comedy';
d176 1
a176 1
   SELECT * FROM kinds;
d178 4
a181 4
   code |title                    |did| date_prod|kind      |len
   -----+-------------------------+---+----------+----------+------
   UA502|Bananas                  |105|1971-07-13|Comedy    | 01:22
   C_701|There's a Girl in my Soup|107|1970-06-11|Comedy    | 01:36
d195 1
a195 1
    <DATE>1998-04-15</DATE>
d203 7
a209 7
   <programlisting>
    CREATE VIEW <replaceable class="parameter">view</replaceable> [ <replaceable class="parameter">column</replaceable> [, ...] ]
      AS SELECT <replaceable class="parameter">expression</replaceable> [AS <replaceable class="parameter">colname</replaceable>] [, ...]
         FROM <replaceable class="parameter">table</replaceable>
         [WHERE <replaceable class="parameter">condition</replaceable>]
         [ WITH [ CASCADE | LOCAL ] CHECK OPTION ]
   </programlisting>
d220 1
a220 1
	  <ReturnValue>CHECK OPTION</ReturnValue>
d232 1
a232 1
	  <ReturnValue>LOCAL</ReturnValue>
d242 1
a242 1
	  <ReturnValue>CASCADE</ReturnValue>
@


1.1
log
@Add new files from Oliver and Thomas.
@
text
@d1 1
a1 1
<REFENTRY ID="SQL-CREATEVIEW-1">
d285 1
a285 1
-->@
