diff --git a/doc/src/sgml/ref/alter_aggregate.sgml b/doc/src/sgml/ref/alter_aggregate.sgml
index bfdb1761d5b..b8d90751235 100644
--- a/doc/src/sgml/ref/alter_aggregate.sgml
+++ b/doc/src/sgml/ref/alter_aggregate.sgml
@@ -1,5 +1,5 @@
@@ -20,8 +20,9 @@ PostgreSQL documentation
-ALTER AGGREGATE name ( type ) RENAME TO newname
-ALTER AGGREGATE name ( type ) OWNER TO newowner
+ALTER AGGREGATE name ( type ) RENAME TO new_name
+ALTER AGGREGATE name ( type ) OWNER TO new_owner
+ALTER AGGREGATE name ( type ) SET SCHEMA new_schema
@@ -32,6 +33,14 @@ ALTER AGGREGATE name ( typeALTER AGGREGATE changes the definition of an
aggregate function.
+
+
+ You must own the aggregate function to use ALTER AGGREGATE>;
+ except for ALTER AGGREGATE OWNER>, which may only be executed by
+ a superuser.
+ To change the schema of an aggregate function, you must also have
+ CREATE privilege on the new schema.
+
@@ -58,7 +67,7 @@ ALTER AGGREGATE name ( type
- newname
+ new_name
The new name of the aggregate function.
@@ -67,11 +76,19 @@ ALTER AGGREGATE name ( type
- newowner
+ new_owner
The new owner of the aggregate function.
- You must be a superuser to change an aggregate's owner.
+
+
+
+
+
+ new_schema
+
+
+ The new schema for the aggregate function.
@@ -94,6 +111,14 @@ ALTER AGGREGATE myavg(integer) RENAME TO my_average;
integer to joe:
ALTER AGGREGATE myavg(integer) OWNER TO joe;
+
+
+
+
+ To move the aggregate function myavg for type
+ integer into schema myschema:
+
+ALTER AGGREGATE myavg(integer) SET SCHEMA myschema;
diff --git a/doc/src/sgml/ref/alter_domain.sgml b/doc/src/sgml/ref/alter_domain.sgml
index deb4050174c..4cc6b25018b 100644
--- a/doc/src/sgml/ref/alter_domain.sgml
+++ b/doc/src/sgml/ref/alter_domain.sgml
@@ -1,5 +1,5 @@
@@ -34,6 +34,8 @@ ALTER DOMAIN name
DROP CONSTRAINT constraint_name [ RESTRICT | CASCADE ]
ALTER DOMAIN name
OWNER TO new_owner
+ALTER DOMAIN name
+ SET SCHEMA new_schema
@@ -97,11 +99,23 @@ ALTER DOMAIN name
+
+
+ SET SCHEMA
+
+
+ This form changes the schema of the domain. Any constraints
+ associated with the domain are moved into the new schema as well.
+
+
+
You must own the domain to use ALTER DOMAIN>; except for
ALTER DOMAIN OWNER>, which may only be executed by a superuser.
+ To change a domain's schema, you must also have CREATE>
+ privilege on the new schema.
@@ -114,8 +128,8 @@ ALTER DOMAIN name
name
- The name (possibly schema-qualified) of an existing domain to
- alter.
+ The name (possibly schema-qualified) of an existing domain to
+ alter.
@@ -124,7 +138,7 @@ ALTER DOMAIN name
domain_constraint
- New domain constraint for the domain.
+ New domain constraint for the domain.
@@ -133,7 +147,7 @@ ALTER DOMAIN name
constraint_name
- Name of an existing constraint to drop.
+ Name of an existing constraint to drop.
@@ -152,7 +166,7 @@ ALTER DOMAIN name
Refuse to drop the constraint if there are any dependent
- objects. This is the default behavior.
+ objects. This is the default behavior.
@@ -161,7 +175,16 @@ ALTER DOMAIN name
new_owner
- The user name of the new owner of the domain.
+ The user name of the new owner of the domain.
+
+
+
+
+
+ new_schema
+
+
+ The new schema for the domain.
@@ -197,15 +220,22 @@ ALTER DOMAIN zipcode ADD CONSTRAINT zipchk CHECK (char_length(VALUE) = 5);
ALTER DOMAIN zipcode DROP CONSTRAINT zipchk;
+
+
+ To move the domain into a different schema:
+
+ALTER DOMAIN zipcode SET SCHEMA customers;
+
+
Compatibility
- The ALTER DOMAIN statement is compatible with SQL:2003,
- except for the OWNER> variant, which is a
- PostgreSQL extension.
+ ALTER DOMAIN conforms with SQL:2003,
+ except for the OWNER> and SET SCHEMA> variants,
+ which are PostgreSQL extensions.
diff --git a/doc/src/sgml/ref/alter_function.sgml b/doc/src/sgml/ref/alter_function.sgml
index 2f4b901f48e..211a350f840 100644
--- a/doc/src/sgml/ref/alter_function.sgml
+++ b/doc/src/sgml/ref/alter_function.sgml
@@ -1,5 +1,5 @@
@@ -23,9 +23,11 @@ PostgreSQL documentation
ALTER FUNCTION name ( [ [ argmode ] [ argname ] argtype [, ...] ] )
action [, ... ] [ RESTRICT ]
ALTER FUNCTION name ( [ [ argmode ] [ argname ] argtype [, ...] ] )
- RENAME TO newname
+ RENAME TO new_name
ALTER FUNCTION name ( [ [ argmode ] [ argname ] argtype [, ...] ] )
- OWNER TO newowner
+ OWNER TO new_owner
+ALTER FUNCTION name ( [ [ argmode ] [ argname ] argtype [, ...] ] )
+ SET SCHEMA new_schema
where action is one of:
@@ -42,6 +44,13 @@ where action is one of:
ALTER FUNCTION changes the definition of a
function.
+
+
+ You must own the function to use ALTER FUNCTION>; except for
+ ALTER FUNCTION OWNER>, which may only be executed by a superuser.
+ To change a function's schema, you must also have CREATE>
+ privilege on the new schema.
+
@@ -98,7 +107,7 @@ where action is one of:
- newname
+ new_name
The new name of the function.
@@ -107,17 +116,25 @@ where action is one of:
- newowner
+ new_owner
- The new owner of the function. To change the owner of a
- function, you must be a superuser. Note that if the function is
+ The new owner of the function. Note that if the function is
marked SECURITY DEFINER, it will subsequently
execute as the new owner.
+
+ new_schema
+
+
+ The new schema for the function.
+
+
+
+
CALLED ON NULL INPUT
RETURNS NULL ON NULL INPUT
@@ -191,6 +208,14 @@ ALTER FUNCTION sqrt(integer) RENAME TO square_root;
integer to joe:
ALTER FUNCTION sqrt(integer) OWNER TO joe;
+
+
+
+
+ To change the schema of the function sqrt for type
+ integer to maths:
+
+ALTER FUNCTION sqrt(integer) SET SCHEMA maths;
@@ -203,7 +228,7 @@ ALTER FUNCTION sqrt(integer) OWNER TO joe;
FUNCTION> statement in the SQL standard. The standard allows more
properties of a function to be modified, but does not provide the
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 RESTRICT> key word; it is optional in
PostgreSQL>.
diff --git a/doc/src/sgml/ref/alter_sequence.sgml b/doc/src/sgml/ref/alter_sequence.sgml
index a96b1d722af..413dfbdde63 100644
--- a/doc/src/sgml/ref/alter_sequence.sgml
+++ b/doc/src/sgml/ref/alter_sequence.sgml
@@ -1,5 +1,5 @@
@@ -27,6 +27,7 @@ PostgreSQL documentation
ALTER SEQUENCE name [ INCREMENT [ BY ] increment ]
[ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ]
[ RESTART [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ]
+ALTER SEQUENCE name SET SCHEMA new_schema
@@ -35,8 +36,14 @@ ALTER SEQUENCE name [ INCREMENT [ B
ALTER SEQUENCE changes the parameters of an existing
- sequence generator. Any parameter not specifically set in the
- ALTER SEQUENCE command retains its prior setting.
+ sequence generator. Any parameters not specifically set in the
+ ALTER SEQUENCE command retain their prior settings.
+
+
+
+ You must own the sequence to use ALTER SEQUENCE>.
+ To change a sequence's schema, you must also have CREATE>
+ privilege on the new schema.
@@ -155,6 +162,15 @@ ALTER SEQUENCE name [ INCREMENT [ B
+
+
+ new_schema
+
+
+ The new schema for the sequence.
+
+
+
@@ -186,6 +202,12 @@ ALTER SEQUENCE serial RESTART WITH 105;
values. They will use up all cached values prior to noticing the changed
sequence parameters. The current backend will be affected immediately.
+
+
+ Some variants of ALTER TABLE can be used with
+ sequences as well; for example, to rename a sequence use ALTER
+ TABLE RENAME.
+
@@ -193,7 +215,9 @@ ALTER SEQUENCE serial RESTART WITH 105;
Compatibility
- ALTER SEQUENCE conforms with SQL:2003.
+ ALTER SEQUENCE conforms with SQL:2003,
+ except for the SET SCHEMA variant, which is a
+ PostgreSQL extension.
diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index b3268042330..26dabbb79ec 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -1,5 +1,5 @@
@@ -26,6 +26,8 @@ ALTER TABLE [ ONLY ] name [ * ]
RENAME [ COLUMN ] column TO new_column
ALTER TABLE name
RENAME TO new_name
+ALTER TABLE name
+ SET SCHEMA new_schema
where action is one of:
@@ -43,7 +45,7 @@ where action is one of:
SET WITHOUT CLUSTER
SET WITHOUT OIDS
OWNER TO new_owner
- SET TABLESPACE tablespace_name
+ SET TABLESPACE new_tablespace
@@ -59,7 +61,7 @@ where action is one of:
ADD COLUMN
- 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
.
@@ -264,11 +266,22 @@ where action is one of:
+
+ SET SCHEMA
+
+
+ This form moves the table into another schema. Associated indexes,
+ constraints, and SERIAL-column sequences are moved as well.
+
+
+
+
- All the actions except RENAME can be combined into
+ All the actions except RENAME and SET SCHEMA>
+ can be combined into
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
columns in a single command. This is particularly useful with large
@@ -278,6 +291,8 @@ where action is one of:
You must own the table to use ALTER TABLE>; except for
ALTER TABLE OWNER>, which may only be executed by a superuser.
+ To change the schema of a table, you must also have
+ CREATE privilege on the new schema.
@@ -397,10 +412,19 @@ where action is one of:
- tablespace_name
+ new_tablespace
- The tablespace name to which the table will be moved.
+ The name of the tablespace to which the table will be moved.
+
+
+
+
+
+ new_schema
+
+
+ The name of the schema to which the table will be moved.
@@ -610,9 +634,16 @@ ALTER TABLE distributors ADD PRIMARY KEY (dist_id);
- To move a table to a different tablespace:
+ To move a table to a different tablespace:
ALTER TABLE distributors SET TABLESPACE fasttablespace;
+
+
+
+
+ To move a table to a different schema:
+
+ALTER TABLE myschema.distributors SET SCHEMA yourschema;
diff --git a/doc/src/sgml/ref/alter_type.sgml b/doc/src/sgml/ref/alter_type.sgml
index 33830c04c04..915a1bd1bab 100644
--- a/doc/src/sgml/ref/alter_type.sgml
+++ b/doc/src/sgml/ref/alter_type.sgml
@@ -1,5 +1,5 @@
@@ -25,6 +25,7 @@ PostgreSQL documentation
ALTER TYPE name OWNER TO new_owner
+ALTER TYPE name SET SCHEMA new_schema
@@ -33,7 +34,8 @@ ALTER TYPE name OWNER TO
ALTER TYPE 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.
@@ -62,6 +64,17 @@ ALTER TYPE name OWNER TO
+
+ new_schema
+
+
+ The new schema for the type. To move a
+ type to a new schema, you must be the owner of the
+ type and have CREATE> privilege on the new schema.
+
+
+
+
@@ -76,6 +89,14 @@ ALTER TYPE name OWNER TO
+
+
+ To change the schema of the user-defined type email
+ to customers:
+
+ALTER TYPE email SET SCHEMA customers;
+
+