Commit f58434f1 authored by Tom Lane's avatar Tom Lane

Documentation for ALTER object SET SCHEMA commands. Also some minor

editorialization.
parent 614b6e25
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_aggregate.sgml,v 1.5 2004/06/25 21:55:50 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/alter_aggregate.sgml,v 1.6 2005/08/01 16:11:14 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -20,8 +20,9 @@ PostgreSQL documentation ...@@ -20,8 +20,9 @@ PostgreSQL documentation
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>type</replaceable> ) RENAME TO <replaceable>newname</replaceable> ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>type</replaceable> ) RENAME TO <replaceable>new_name</replaceable>
ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>type</replaceable> ) OWNER TO <replaceable>newowner</replaceable> ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>type</replaceable> ) OWNER TO <replaceable>new_owner</replaceable>
ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>type</replaceable> ) SET SCHEMA <replaceable>new_schema</replaceable>
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
...@@ -32,6 +33,14 @@ ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>type</replaceable ...@@ -32,6 +33,14 @@ ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>type</replaceable
<command>ALTER AGGREGATE</command> changes the definition of an <command>ALTER AGGREGATE</command> changes the definition of an
aggregate function. aggregate function.
</para> </para>
<para>
You must own the aggregate function to use <command>ALTER AGGREGATE</>;
except for <command>ALTER AGGREGATE OWNER</>, which may only be executed by
a superuser.
To change the schema of an aggregate function, you must also have
<literal>CREATE</literal> privilege on the new schema.
</para>
</refsect1> </refsect1>
<refsect1> <refsect1>
...@@ -58,7 +67,7 @@ ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>type</replaceable ...@@ -58,7 +67,7 @@ ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>type</replaceable
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><replaceable class="parameter">newname</replaceable></term> <term><replaceable class="parameter">new_name</replaceable></term>
<listitem> <listitem>
<para> <para>
The new name of the aggregate function. The new name of the aggregate function.
...@@ -67,11 +76,19 @@ ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>type</replaceable ...@@ -67,11 +76,19 @@ ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>type</replaceable
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><replaceable class="parameter">newowner</replaceable></term> <term><replaceable class="parameter">new_owner</replaceable></term>
<listitem> <listitem>
<para> <para>
The new owner of the aggregate function. The new owner of the aggregate function.
You must be a superuser to change an aggregate's owner. </para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">new_schema</replaceable></term>
<listitem>
<para>
The new schema for the aggregate function.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -94,6 +111,14 @@ ALTER AGGREGATE myavg(integer) RENAME TO my_average; ...@@ -94,6 +111,14 @@ ALTER AGGREGATE myavg(integer) RENAME TO my_average;
<type>integer</type> to <literal>joe</literal>: <type>integer</type> to <literal>joe</literal>:
<programlisting> <programlisting>
ALTER AGGREGATE myavg(integer) OWNER TO joe; ALTER AGGREGATE myavg(integer) OWNER TO joe;
</programlisting>
</para>
<para>
To move the aggregate function <literal>myavg</literal> for type
<type>integer</type> into schema <literal>myschema</literal>:
<programlisting>
ALTER AGGREGATE myavg(integer) SET SCHEMA myschema;
</programlisting> </programlisting>
</para> </para>
</refsect1> </refsect1>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_domain.sgml,v 1.16 2005/07/14 06:17:36 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/alter_domain.sgml,v 1.17 2005/08/01 16:11:14 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -34,6 +34,8 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable> ...@@ -34,6 +34,8 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
DROP CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> [ RESTRICT | CASCADE ] DROP CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> [ RESTRICT | CASCADE ]
ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable> ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
OWNER TO <replaceable class="PARAMETER">new_owner</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
SET SCHEMA <replaceable class="PARAMETER">new_schema</replaceable>
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
...@@ -97,11 +99,23 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable> ...@@ -97,11 +99,23 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>SET SCHEMA</term>
<listitem>
<para>
This form changes the schema of the domain. Any constraints
associated with the domain are moved into the new schema as well.
</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
<para> <para>
You must own the domain to use <command>ALTER DOMAIN</>; except for You must own the domain to use <command>ALTER DOMAIN</>; except for
<command>ALTER DOMAIN OWNER</>, which may only be executed by a superuser. <command>ALTER DOMAIN OWNER</>, which may only be executed by a superuser.
To change a domain's schema, you must also have <literal>CREATE</>
privilege on the new schema.
</para> </para>
</refsect1> </refsect1>
...@@ -114,8 +128,8 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable> ...@@ -114,8 +128,8 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
<term><replaceable class="PARAMETER">name</replaceable></term> <term><replaceable class="PARAMETER">name</replaceable></term>
<listitem> <listitem>
<para> <para>
The name (possibly schema-qualified) of an existing domain to The name (possibly schema-qualified) of an existing domain to
alter. alter.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -124,7 +138,7 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable> ...@@ -124,7 +138,7 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
<term><replaceable class="PARAMETER">domain_constraint</replaceable></term> <term><replaceable class="PARAMETER">domain_constraint</replaceable></term>
<listitem> <listitem>
<para> <para>
New domain constraint for the domain. New domain constraint for the domain.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -133,7 +147,7 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable> ...@@ -133,7 +147,7 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
<term><replaceable class="PARAMETER">constraint_name</replaceable></term> <term><replaceable class="PARAMETER">constraint_name</replaceable></term>
<listitem> <listitem>
<para> <para>
Name of an existing constraint to drop. Name of an existing constraint to drop.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -152,7 +166,7 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable> ...@@ -152,7 +166,7 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
<listitem> <listitem>
<para> <para>
Refuse to drop the constraint if there are any dependent Refuse to drop the constraint if there are any dependent
objects. This is the default behavior. objects. This is the default behavior.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -161,7 +175,16 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable> ...@@ -161,7 +175,16 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
<term><replaceable class="PARAMETER">new_owner</replaceable></term> <term><replaceable class="PARAMETER">new_owner</replaceable></term>
<listitem> <listitem>
<para> <para>
The user name of the new owner of the domain. The user name of the new owner of the domain.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="PARAMETER">new_schema</replaceable></term>
<listitem>
<para>
The new schema for the domain.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -197,15 +220,22 @@ ALTER DOMAIN zipcode ADD CONSTRAINT zipchk CHECK (char_length(VALUE) = 5); ...@@ -197,15 +220,22 @@ ALTER DOMAIN zipcode ADD CONSTRAINT zipchk CHECK (char_length(VALUE) = 5);
ALTER DOMAIN zipcode DROP CONSTRAINT zipchk; ALTER DOMAIN zipcode DROP CONSTRAINT zipchk;
</programlisting> </programlisting>
</para> </para>
<para>
To move the domain into a different schema:
<programlisting>
ALTER DOMAIN zipcode SET SCHEMA customers;
</programlisting>
</para>
</refsect1> </refsect1>
<refsect1 id="SQL-ALTERDOMAIN-compatibility"> <refsect1 id="SQL-ALTERDOMAIN-compatibility">
<title>Compatibility</title> <title>Compatibility</title>
<para> <para>
The <command>ALTER DOMAIN</command> statement is compatible with SQL:2003, <command>ALTER DOMAIN</command> conforms with <acronym>SQL:2003</acronym>,
except for the <literal>OWNER</> variant, which is a except for the <literal>OWNER</> and <literal>SET SCHEMA</> variants,
<productname>PostgreSQL</productname> extension. which are <productname>PostgreSQL</productname> extensions.
</para> </para>
</refsect1> </refsect1>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_function.sgml,v 1.7 2005/05/26 20:05:03 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/alter_function.sgml,v 1.8 2005/08/01 16:11:14 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -23,9 +23,11 @@ PostgreSQL documentation ...@@ -23,9 +23,11 @@ PostgreSQL documentation
ALTER FUNCTION <replaceable>name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) ALTER FUNCTION <replaceable>name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] )
<replaceable class="PARAMETER">action</replaceable> [, ... ] [ RESTRICT ] <replaceable class="PARAMETER">action</replaceable> [, ... ] [ RESTRICT ]
ALTER FUNCTION <replaceable>name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) ALTER FUNCTION <replaceable>name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] )
RENAME TO <replaceable>newname</replaceable> RENAME TO <replaceable>new_name</replaceable>
ALTER FUNCTION <replaceable>name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) ALTER FUNCTION <replaceable>name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] )
OWNER TO <replaceable>newowner</replaceable> OWNER TO <replaceable>new_owner</replaceable>
ALTER FUNCTION <replaceable>name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] )
SET SCHEMA <replaceable>new_schema</replaceable>
where <replaceable class="PARAMETER">action</replaceable> is one of: where <replaceable class="PARAMETER">action</replaceable> is one of:
...@@ -42,6 +44,13 @@ where <replaceable class="PARAMETER">action</replaceable> is one of: ...@@ -42,6 +44,13 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
<command>ALTER FUNCTION</command> changes the definition of a <command>ALTER FUNCTION</command> changes the definition of a
function. function.
</para> </para>
<para>
You must own the function to use <command>ALTER FUNCTION</>; except for
<command>ALTER FUNCTION OWNER</>, which may only be executed by a superuser.
To change a function's schema, you must also have <literal>CREATE</>
privilege on the new schema.
</para>
</refsect1> </refsect1>
<refsect1> <refsect1>
...@@ -98,7 +107,7 @@ where <replaceable class="PARAMETER">action</replaceable> is one of: ...@@ -98,7 +107,7 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><replaceable class="parameter">newname</replaceable></term> <term><replaceable class="parameter">new_name</replaceable></term>
<listitem> <listitem>
<para> <para>
The new name of the function. The new name of the function.
...@@ -107,17 +116,25 @@ where <replaceable class="PARAMETER">action</replaceable> is one of: ...@@ -107,17 +116,25 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><replaceable class="parameter">newowner</replaceable></term> <term><replaceable class="parameter">new_owner</replaceable></term>
<listitem> <listitem>
<para> <para>
The new owner of the function. To change the owner of a The new owner of the function. Note that if the function is
function, you must be a superuser. Note that if the function is
marked <literal>SECURITY DEFINER</literal>, it will subsequently marked <literal>SECURITY DEFINER</literal>, it will subsequently
execute as the new owner. execute as the new owner.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><replaceable class="parameter">new_schema</replaceable></term>
<listitem>
<para>
The new schema for the function.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><literal>CALLED ON NULL INPUT</literal></term> <term><literal>CALLED ON NULL INPUT</literal></term>
<term><literal>RETURNS NULL ON NULL INPUT</literal></term> <term><literal>RETURNS NULL ON NULL INPUT</literal></term>
...@@ -191,6 +208,14 @@ ALTER FUNCTION sqrt(integer) RENAME TO square_root; ...@@ -191,6 +208,14 @@ ALTER FUNCTION sqrt(integer) RENAME TO square_root;
<type>integer</type> to <literal>joe</literal>: <type>integer</type> to <literal>joe</literal>:
<programlisting> <programlisting>
ALTER FUNCTION sqrt(integer) OWNER TO joe; ALTER FUNCTION sqrt(integer) OWNER TO joe;
</programlisting>
</para>
<para>
To change the schema of the function <literal>sqrt</literal> for type
<type>integer</type> to <literal>maths</literal>:
<programlisting>
ALTER FUNCTION sqrt(integer) SET SCHEMA maths;
</programlisting> </programlisting>
</para> </para>
</refsect1> </refsect1>
...@@ -203,7 +228,7 @@ ALTER FUNCTION sqrt(integer) OWNER TO joe; ...@@ -203,7 +228,7 @@ ALTER FUNCTION sqrt(integer) OWNER TO joe;
FUNCTION</> statement in the SQL standard. The standard allows more FUNCTION</> statement in the SQL standard. The standard allows more
properties of a function to be modified, but does not provide the properties of a function to be modified, but does not provide the
ability to rename a function, make a function a security definer, ability to rename a function, make a function a security definer,
or change the owner or volatility of a function. The standard also or change the owner, schema, or volatility of a function. The standard also
requires the <literal>RESTRICT</> key word; it is optional in requires the <literal>RESTRICT</> key word; it is optional in
<productname>PostgreSQL</>. <productname>PostgreSQL</>.
</para> </para>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_sequence.sgml,v 1.9 2004/11/27 21:27:07 petere Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/alter_sequence.sgml,v 1.10 2005/08/01 16:11:14 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -27,6 +27,7 @@ PostgreSQL documentation ...@@ -27,6 +27,7 @@ PostgreSQL documentation
ALTER SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ BY ] <replaceable class="parameter">increment</replaceable> ] ALTER SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ BY ] <replaceable class="parameter">increment</replaceable> ]
[ MINVALUE <replaceable class="parameter">minvalue</replaceable> | NO MINVALUE ] [ MAXVALUE <replaceable class="parameter">maxvalue</replaceable> | NO MAXVALUE ] [ MINVALUE <replaceable class="parameter">minvalue</replaceable> | NO MINVALUE ] [ MAXVALUE <replaceable class="parameter">maxvalue</replaceable> | NO MAXVALUE ]
[ RESTART [ WITH ] <replaceable class="parameter">start</replaceable> ] [ CACHE <replaceable class="parameter">cache</replaceable> ] [ [ NO ] CYCLE ] [ RESTART [ WITH ] <replaceable class="parameter">start</replaceable> ] [ CACHE <replaceable class="parameter">cache</replaceable> ] [ [ NO ] CYCLE ]
ALTER SEQUENCE <replaceable class="parameter">name</replaceable> SET SCHEMA <replaceable class="parameter">new_schema</replaceable>
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
...@@ -35,8 +36,14 @@ ALTER SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ B ...@@ -35,8 +36,14 @@ ALTER SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ B
<para> <para>
<command>ALTER SEQUENCE</command> changes the parameters of an existing <command>ALTER SEQUENCE</command> changes the parameters of an existing
sequence generator. Any parameter not specifically set in the sequence generator. Any parameters not specifically set in the
<command>ALTER SEQUENCE</command> command retains its prior setting. <command>ALTER SEQUENCE</command> command retain their prior settings.
</para>
<para>
You must own the sequence to use <command>ALTER SEQUENCE</>.
To change a sequence's schema, you must also have <literal>CREATE</>
privilege on the new schema.
</para> </para>
</refsect1> </refsect1>
...@@ -155,6 +162,15 @@ ALTER SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ B ...@@ -155,6 +162,15 @@ ALTER SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ B
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><replaceable class="parameter">new_schema</replaceable></term>
<listitem>
<para>
The new schema for the sequence.
</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</para> </para>
</refsect1> </refsect1>
...@@ -186,6 +202,12 @@ ALTER SEQUENCE serial RESTART WITH 105; ...@@ -186,6 +202,12 @@ ALTER SEQUENCE serial RESTART WITH 105;
values. They will use up all cached values prior to noticing the changed values. They will use up all cached values prior to noticing the changed
sequence parameters. The current backend will be affected immediately. sequence parameters. The current backend will be affected immediately.
</para> </para>
<para>
Some variants of <command>ALTER TABLE</command> can be used with
sequences as well; for example, to rename a sequence use <command>ALTER
TABLE RENAME</command>.
</para>
</refsect1> </refsect1>
...@@ -193,7 +215,9 @@ ALTER SEQUENCE serial RESTART WITH 105; ...@@ -193,7 +215,9 @@ ALTER SEQUENCE serial RESTART WITH 105;
<title>Compatibility</title> <title>Compatibility</title>
<para> <para>
<command>ALTER SEQUENCE</command> conforms with <acronym>SQL:2003</acronym>. <command>ALTER SEQUENCE</command> conforms with <acronym>SQL:2003</acronym>,
except for the <literal>SET SCHEMA</literal> variant, which is a
<productname>PostgreSQL</productname> extension.
</para> </para>
</refsect1> </refsect1>
</refentry> </refentry>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.77 2005/01/14 01:16:52 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.78 2005/08/01 16:11:14 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -26,6 +26,8 @@ ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">name</replaceable> [ * ] ...@@ -26,6 +26,8 @@ ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">name</replaceable> [ * ]
RENAME [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> TO <replaceable class="PARAMETER">new_column</replaceable> RENAME [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> TO <replaceable class="PARAMETER">new_column</replaceable>
ALTER TABLE <replaceable class="PARAMETER">name</replaceable> ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
RENAME TO <replaceable class="PARAMETER">new_name</replaceable> RENAME TO <replaceable class="PARAMETER">new_name</replaceable>
ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
SET SCHEMA <replaceable class="PARAMETER">new_schema</replaceable>
where <replaceable class="PARAMETER">action</replaceable> is one of: where <replaceable class="PARAMETER">action</replaceable> is one of:
...@@ -43,7 +45,7 @@ where <replaceable class="PARAMETER">action</replaceable> is one of: ...@@ -43,7 +45,7 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
SET WITHOUT CLUSTER SET WITHOUT CLUSTER
SET WITHOUT OIDS SET WITHOUT OIDS
OWNER TO <replaceable class="PARAMETER">new_owner</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
SET TABLESPACE <replaceable class="PARAMETER">tablespace_name</replaceable> SET TABLESPACE <replaceable class="PARAMETER">new_tablespace</replaceable>
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
...@@ -59,7 +61,7 @@ where <replaceable class="PARAMETER">action</replaceable> is one of: ...@@ -59,7 +61,7 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
<term><literal>ADD COLUMN</literal></term> <term><literal>ADD COLUMN</literal></term>
<listitem> <listitem>
<para> <para>
This form adds a new column to the table using the same syntax as This form adds a new column to the table, using the same syntax as
<xref linkend="SQL-CREATETABLE" endterm="SQL-CREATETABLE-TITLE">. <xref linkend="SQL-CREATETABLE" endterm="SQL-CREATETABLE-TITLE">.
</para> </para>
</listitem> </listitem>
...@@ -264,11 +266,22 @@ where <replaceable class="PARAMETER">action</replaceable> is one of: ...@@ -264,11 +266,22 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><literal>SET SCHEMA</literal></term>
<listitem>
<para>
This form moves the table into another schema. Associated indexes,
constraints, and SERIAL-column sequences are moved as well.
</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</para> </para>
<para> <para>
All the actions except <literal>RENAME</literal> can be combined into All the actions except <literal>RENAME</literal> and <literal>SET SCHEMA</>
can be combined into
a list of multiple alterations to apply in parallel. For example, it a list of multiple alterations to apply in parallel. For example, it
is possible to add several columns and/or alter the type of several is possible to add several columns and/or alter the type of several
columns in a single command. This is particularly useful with large columns in a single command. This is particularly useful with large
...@@ -278,6 +291,8 @@ where <replaceable class="PARAMETER">action</replaceable> is one of: ...@@ -278,6 +291,8 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
<para> <para>
You must own the table to use <command>ALTER TABLE</>; except for You must own the table to use <command>ALTER TABLE</>; except for
<command>ALTER TABLE OWNER</>, which may only be executed by a superuser. <command>ALTER TABLE OWNER</>, which may only be executed by a superuser.
To change the schema of a table, you must also have
<literal>CREATE</literal> privilege on the new schema.
</para> </para>
</refsect1> </refsect1>
...@@ -397,10 +412,19 @@ where <replaceable class="PARAMETER">action</replaceable> is one of: ...@@ -397,10 +412,19 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><replaceable class="PARAMETER">tablespace_name</replaceable></term> <term><replaceable class="PARAMETER">new_tablespace</replaceable></term>
<listitem>
<para>
The name of the tablespace to which the table will be moved.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="PARAMETER">new_schema</replaceable></term>
<listitem> <listitem>
<para> <para>
The tablespace name to which the table will be moved. The name of the schema to which the table will be moved.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -610,9 +634,16 @@ ALTER TABLE distributors ADD PRIMARY KEY (dist_id); ...@@ -610,9 +634,16 @@ ALTER TABLE distributors ADD PRIMARY KEY (dist_id);
</para> </para>
<para> <para>
To move a table to a different tablespace: To move a table to a different tablespace:
<programlisting> <programlisting>
ALTER TABLE distributors SET TABLESPACE fasttablespace; ALTER TABLE distributors SET TABLESPACE fasttablespace;
</programlisting>
</para>
<para>
To move a table to a different schema:
<programlisting>
ALTER TABLE myschema.distributors SET SCHEMA yourschema;
</programlisting> </programlisting>
</para> </para>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_type.sgml,v 1.1 2004/06/25 21:55:50 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/alter_type.sgml,v 1.2 2005/08/01 16:11:14 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -25,6 +25,7 @@ PostgreSQL documentation ...@@ -25,6 +25,7 @@ PostgreSQL documentation
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
ALTER TYPE <replaceable class="PARAMETER">name</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable> ALTER TYPE <replaceable class="PARAMETER">name</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
ALTER TYPE <replaceable class="PARAMETER">name</replaceable> SET SCHEMA <replaceable class="PARAMETER">new_schema</replaceable>
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
...@@ -33,7 +34,8 @@ ALTER TYPE <replaceable class="PARAMETER">name</replaceable> OWNER TO <replaceab ...@@ -33,7 +34,8 @@ ALTER TYPE <replaceable class="PARAMETER">name</replaceable> OWNER TO <replaceab
<para> <para>
<command>ALTER TYPE</command> changes the definition of an existing type. <command>ALTER TYPE</command> changes the definition of an existing type.
The only currently available capability is changing the owner of a type. The only currently available capabilities are changing the owner and schema
of a type.
</para> </para>
</refsect1> </refsect1>
...@@ -62,6 +64,17 @@ ALTER TYPE <replaceable class="PARAMETER">name</replaceable> OWNER TO <replaceab ...@@ -62,6 +64,17 @@ ALTER TYPE <replaceable class="PARAMETER">name</replaceable> OWNER TO <replaceab
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><replaceable class="PARAMETER">new_schema</replaceable></term>
<listitem>
<para>
The new schema for the type. To move a
type to a new schema, you must be the owner of the
type and have <literal>CREATE</> privilege on the new schema.
</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</para> </para>
</refsect1> </refsect1>
...@@ -76,6 +89,14 @@ ALTER TYPE <replaceable class="PARAMETER">name</replaceable> OWNER TO <replaceab ...@@ -76,6 +89,14 @@ ALTER TYPE <replaceable class="PARAMETER">name</replaceable> OWNER TO <replaceab
ALTER TYPE email OWNER TO joe; ALTER TYPE email OWNER TO joe;
</programlisting> </programlisting>
</para> </para>
<para>
To change the schema of the user-defined type <literal>email</literal>
to <literal>customers</literal>:
<programlisting>
ALTER TYPE email SET SCHEMA customers;
</programlisting>
</para>
</refsect1> </refsect1>
<refsect1> <refsect1>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment