1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-14 08:21:07 +03:00

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.
This commit is contained in:
Neil Conway
2007-07-03 01:30:37 +00:00
parent a1587e41ae
commit a55898131e
12 changed files with 184 additions and 26 deletions

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.70 2007/04/26 16:13:08 neilc Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.71 2007/07/03 01:30:35 neilc Exp $
PostgreSQL documentation
Complete list of usable sgml source files in this directory.
-->
@ -25,6 +25,7 @@ Complete list of usable sgml source files in this directory.
<!entity alterTrigger system "alter_trigger.sgml">
<!entity alterType system "alter_type.sgml">
<!entity alterUser system "alter_user.sgml">
<!entity alterView system "alter_view.sgml">
<!entity analyze system "analyze.sgml">
<!entity begin system "begin.sgml">
<!entity checkpoint system "checkpoint.sgml">

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_sequence.sgml,v 1.16 2007/01/31 23:26:02 momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_sequence.sgml,v 1.17 2007/07/03 01:30:35 neilc Exp $
PostgreSQL documentation
-->
@ -29,6 +29,7 @@ ALTER SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ B
[ RESTART [ WITH ] <replaceable class="parameter">start</replaceable> ] [ CACHE <replaceable class="parameter">cache</replaceable> ] [ [ NO ] CYCLE ]
[ OWNED BY { <replaceable class="parameter">table</replaceable>.<replaceable class="parameter">column</replaceable> | NONE } ]
ALTER SEQUENCE <replaceable class="parameter">name</replaceable> SET SCHEMA <replaceable class="parameter">new_schema</replaceable>
ALTER SEQUENCE <replaceable class="parameter">name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable>
</synopsis>
</refsynopsisdiv>
@ -182,14 +183,24 @@ ALTER SEQUENCE <replaceable class="parameter">name</replaceable> SET SCHEMA <rep
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">new_schema</replaceable></term>
<listitem>
<para>
The new schema for the sequence.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">new_schema</replaceable></term>
<listitem>
<para>
The new schema for the sequence.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">new_name</replaceable></term>
<listitem>
<para>
The new name for the sequence.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>

View File

@ -0,0 +1,88 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_view.sgml,v 1.1 2007/07/03 01:30:35 neilc Exp $
PostgreSQL documentation
-->
<refentry id="SQL-ALTERVIEW">
<refmeta>
<refentrytitle id="SQL-ALTERVIEW-TITLE">ALTER VIEW</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>ALTER VIEW</refname>
<refpurpose>change the definition of a view</refpurpose>
</refnamediv>
<indexterm zone="sql-alterview">
<primary>ALTER VIEW</primary>
</indexterm>
<refsynopsisdiv>
<synopsis>
ALTER VIEW <replaceable>name</replaceable> RENAME TO <replaceable>newname</replaceable>
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>ALTER VIEW</command> changes the definition of a
view. To execute this command you must be the owner of the view.
</para>
</refsect1>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term><replaceable class="parameter">name</replaceable></term>
<listitem>
<para>
The name (optionally schema-qualified) of an existing view.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">newname</replaceable></term>
<listitem>
<para>
The new name of the view.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Examples</title>
<para>
To rename the view <literal>foo</literal> to
<literal>bar</literal>:
<programlisting>
ALTER VIEW foo RENAME TO bar;
</programlisting>
</para>
<refsect1>
<title>Compatibility</title>
<para>
<command>ALTER VIEW</command> is a <productname>PostgreSQL</>
extension of the SQL standard.
</para>
</refsect1>
<refsect1>
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="sql-createview" endterm="sql-createview-title"></member>
<member><xref linkend="sql-dropview" endterm="sql-dropview-title"></member>
</simplelist>
</refsect1>
</refentry>

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.35 2007/02/01 00:28:18 momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.36 2007/07/03 01:30:35 neilc Exp $
PostgreSQL documentation
-->
@ -226,6 +226,7 @@ CREATE VIEW <replaceable class="parameter">name</replaceable> [ ( <replaceable c
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="sql-alterview" endterm="sql-alterview-title"></member>
<member><xref linkend="sql-dropview" endterm="sql-dropview-title"></member>
</simplelist>
</refsect1>

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_view.sgml,v 1.23 2006/09/16 00:30:18 momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_view.sgml,v 1.24 2007/07/03 01:30:35 neilc Exp $
PostgreSQL documentation
-->
@ -104,6 +104,7 @@ DROP VIEW kinds;
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="sql-alterview" endterm="sql-alterview-title"></member>
<member><xref linkend="sql-createview" endterm="sql-createview-title"></member>
</simplelist>
</refsect1>