1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-08 06:02:22 +03:00

Tablespaces. Alternate database locations are dead, long live tablespaces.

There are various things left to do: contrib dbsize and oid2name modules
need work, and so does the documentation.  Also someone should think about
COMMENT ON TABLESPACE and maybe RENAME TABLESPACE.  Also initlocation is
dead, it just doesn't know it yet.

Gavin Sherry and Tom Lane.
This commit is contained in:
Tom Lane
2004-06-18 06:14:31 +00:00
parent 474875f443
commit 2467394ee1
94 changed files with 3765 additions and 1588 deletions

View File

@@ -1,6 +1,6 @@
<!--
Documentation of the system catalogs, directed toward PostgreSQL developers
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.87 2004/06/16 01:26:33 tgl Exp $
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.88 2004/06/18 06:13:02 tgl Exp $
-->
<chapter id="catalogs">
@@ -178,6 +178,11 @@
<entry>planner statistics</entry>
</row>
<row>
<entry><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link></entry>
<entry>tablespaces within this database cluster</entry>
</row>
<row>
<entry><link linkend="catalog-pg-trigger"><structname>pg_trigger</structname></link></entry>
<entry>triggers</entry>
@@ -1058,6 +1063,17 @@
<entry>Name of the on-disk file of this relation; 0 if none</entry>
</row>
<row>
<entry><structfield>reltablespace</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.oid</literal></entry>
<entry>
The tablespace in which this relation is stored. If zero,
the database's default tablespace is implied. (Not meaningful
if the relation has no on-disk file.)
</entry>
</row>
<row>
<entry><structfield>relpages</structfield></entry>
<entry><type>int4</type></entry>
@@ -1602,13 +1618,15 @@
</row>
<row>
<entry><structfield>datpath</structfield></entry>
<entry><type>text</type></entry>
<entry></entry>
<entry><structfield>dattablespace</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.oid</literal></entry>
<entry>
If the database is stored at an alternative location then this
records the location. It's either an environment variable name
or an absolute path, depending how it was entered.
The default tablespace for the database.
Within this database, all tables for which
<structname>pg_class</>.<structfield>reltablespace</> is zero
will be stored in this tablespace; in particular, all the non-shared
system catalogs will be there.
</entry>
</row>
@@ -2386,6 +2404,17 @@
<entry>Owner of the namespace</entry>
</row>
<row>
<entry><structfield>nsptablespace</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.oid</literal></entry>
<entry>
The default tablespace in which to place relations created in this
namespace. If zero, the database's default tablespace is implied.
(Changing this does not affect pre-existing relations.)
</entry>
</row>
<row>
<entry><structfield>nspacl</structfield></entry>
<entry><type>aclitem[]</type></entry>
@@ -3232,6 +3261,73 @@
</sect1>
<sect1 id="catalog-pg-tablespace">
<title><structname>pg_tablespace</structname></title>
<indexterm zone="catalog-pg-tablespace">
<primary>pg_tablespace</primary>
</indexterm>
<para>
The catalog <structname>pg_tablespace</structname> stores information
about the available tablespaces. Tables can be placed in particular
tablespaces to aid administration of disk layout.
</para>
<para>
Unlike most system catalogs, <structname>pg_tablespace</structname>
is shared across all databases of a cluster: there is only one
copy of <structname>pg_tablespace</structname> per cluster, not
one per database.
</para>
<table>
<title><structname>pg_tablespace</> Columns</title>
<tgroup cols=4>
<thead>
<row>
<entry>Name</entry>
<entry>Type</entry>
<entry>References</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><structfield>spcname</structfield></entry>
<entry><type>name</type></entry>
<entry></entry>
<entry>Tablespace name</entry>
</row>
<row>
<entry><structfield>spcowner</structfield></entry>
<entry><type>int4</type></entry>
<entry><literal><link linkend="catalog-pg-shadow"><structname>pg_shadow</structname></link>.usesysid</literal></entry>
<entry>Owner of the tablespace, usually the user who created it</entry>
</row>
<row>
<entry><structfield>spclocation</structfield></entry>
<entry><type>text</type></entry>
<entry></entry>
<entry>Location (directory path) of the tablespace</entry>
</row>
<row>
<entry><structfield>spcacl</structfield></entry>
<entry><type>aclitem[]</type></entry>
<entry></entry>
<entry>Access privileges</entry>
</row>
</tbody>
</tgroup>
</table>
</sect1>
<sect1 id="catalog-pg-trigger">
<title><structname>pg_trigger</structname></title>

View File

@@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.29 2003/11/29 19:51:37 pgsql Exp $
$PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.30 2004/06/18 06:13:02 tgl Exp $
-->
<chapter id="managing-databases">
@@ -298,6 +298,11 @@ ALTER DATABASE mydb SET geqo TO off;
<sect1 id="manage-ag-alternate-locs">
<title>Alternative Locations</title>
<para>
XXX this is entirely dead now, and needs to be replaced by a DBA-level
description of tablespaces.
</para>
<para>
It is possible to create a database in a location other than the
default location for the installation. But remember that all database access
@@ -368,21 +373,6 @@ CREATE DATABASE <replaceable>name</> WITH LOCATION '<replaceable>location</>';
Databases created in alternative locations can be
accessed and dropped like any other database.
</para>
<note>
<para>
It can also be possible to specify absolute paths directly to the
<command>CREATE DATABASE</> command without defining environment
variables. This is disallowed by default because it is a security
risk. To allow it, you must compile <productname>PostgreSQL</> with
the C preprocessor macro <literal>ALLOW_ABSOLUTE_DBPATHS</>
defined. One way to do this is to run the compilation step like
this:
<programlisting>
gmake CPPFLAGS=-DALLOW_ABSOLUTE_DBPATHS all
</programlisting>
</para>
</note>
</sect1>
<sect1 id="manage-ag-dropdb">

View File

@@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.56 2004/04/20 01:11:49 momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.57 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation
Complete list of usable sgml source files in this directory.
-->
@@ -44,6 +44,7 @@ Complete list of usable sgml source files in this directory.
<!entity createSequence system "create_sequence.sgml">
<!entity createTable system "create_table.sgml">
<!entity createTableAs system "create_table_as.sgml">
<!entity createTableSpace system "create_tablespace.sgml">
<!entity createTrigger system "create_trigger.sgml">
<!entity createType system "create_type.sgml">
<!entity createUser system "create_user.sgml">
@@ -66,6 +67,7 @@ Complete list of usable sgml source files in this directory.
<!entity dropSchema system "drop_schema.sgml">
<!entity dropSequence system "drop_sequence.sgml">
<!entity dropTable system "drop_table.sgml">
<!entity dropTableSpace system "drop_tablespace.sgml">
<!entity dropTrigger system "drop_trigger.sgml">
<!entity dropType system "drop_type.sgml">
<!entity dropUser system "drop_user.sgml">

View File

@@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_database.sgml,v 1.38 2004/03/23 02:47:35 neilc Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_database.sgml,v 1.39 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation
-->
@@ -22,9 +22,9 @@ PostgreSQL documentation
<synopsis>
CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
[ [ WITH ] [ OWNER [=] <replaceable class="parameter">dbowner</replaceable> ]
[ LOCATION [=] '<replaceable class="parameter">dbpath</replaceable>' ]
[ TEMPLATE [=] <replaceable class="parameter">template</replaceable> ]
[ ENCODING [=] <replaceable class="parameter">encoding</replaceable> ] ]
[ ENCODING [=] <replaceable class="parameter">encoding</replaceable> ]
[ TABLESPACE [=] <replaceable class="parameter">tablespace</replaceable> ] ]
</synopsis>
</refsynopsisdiv>
@@ -50,29 +50,6 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
privilege can only create databases owned by themselves.
</para>
<para>
An alternative location can be specified in order to,
for example, store the database on a different disk.
The path must have been prepared with the
<xref linkend="APP-INITLOCATION" endterm="APP-INITLOCATION-title">
command.
</para>
<para>
If the path name does not contain a slash, it is interpreted
as an environment variable name, which must be known to the
server process. This way the database administrator can
exercise control over locations in which databases can be created.
(A customary choice is, e.g., <envar>PGDATA2</envar>.)
If the server is compiled with <literal>ALLOW_ABSOLUTE_DBPATHS</literal>
(not so by default), absolute path names, as identified by
a leading slash
(e.g., <filename>/usr/local/pgsql/data</filename>),
are allowed as well.
In either case, the final path name must be absolute and must not
contain any single quotes.
</para>
<para>
By default, the new database will be created by cloning the standard
system database <literal>template1</>. A different template can be
@@ -83,13 +60,7 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
version of <productname>PostgreSQL</productname>. This is useful
if you wish to avoid copying
any installation-local objects that may have been added to
<literal>template1</>.
</para>
<para>
The optional encoding parameter allows selection of the database
encoding. When not specified, it defaults to the encoding used by
the selected template database.
<literal>template1</>.
</para>
</refsect1>
@@ -101,7 +72,7 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
<term><replaceable class="parameter">name</replaceable></term>
<listitem>
<para>
The name of a database to create.
The name of a database to create.
</para>
</listitem>
</varlistentry>
@@ -110,18 +81,8 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
<listitem>
<para>
The name of the database user who will own the new database,
or <literal>DEFAULT</literal> to use the default (namely, the
user executing the command).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">dbpath</replaceable></term>
<listitem>
<para>
An alternate file-system location in which to store the new database,
specified as a string literal;
or <literal>DEFAULT</literal> to use the default location.
or <literal>DEFAULT</literal> to use the default (namely, the
user executing the command).
</para>
</listitem>
</varlistentry>
@@ -130,8 +91,8 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
<listitem>
<para>
The name of the template from which to create the new database,
or <literal>DEFAULT</literal> to use the default template
(<literal>template1</literal>).
or <literal>DEFAULT</literal> to use the default template
(<literal>template1</literal>).
</para>
</listitem>
</varlistentry>
@@ -139,12 +100,24 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
<term><replaceable class="parameter">encoding</replaceable></term>
<listitem>
<para>
Character set encoding to use in the new database. Specify
a string constant (e.g., <literal>'SQL_ASCII'</literal>),
or an integer encoding number, or <literal>DEFAULT</literal>
to use the default encoding. The character sets supported by the
<productname>PostgreSQL</productname> server are described in
<xref linkend="multibyte-charset-supported">.
Character set encoding to use in the new database. Specify
a string constant (e.g., <literal>'SQL_ASCII'</literal>),
or an integer encoding number, or <literal>DEFAULT</literal>
to use the default encoding. The character sets supported by the
<productname>PostgreSQL</productname> server are described in
<xref linkend="multibyte-charset-supported">.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">tablespace</replaceable></term>
<listitem>
<para>
Specifies the default tablespace for the new database.
If not specified, the same tablespace that is default for
the template database is used. See
<xref linkend="sql-createtablespace" endterm="sql-createtablespace-title">
for more information.
</para>
</listitem>
</varlistentry>
@@ -167,9 +140,7 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
<para>
Errors along the line of <quote>could not initialize database directory</>
are most likely related to insufficient permissions on the data
directory, a full disk, or other file system problems. When using an
alternate location, the user under
which the database server is running must have access to the location.
directory, a full disk, or other file system problems.
</para>
<para>
@@ -181,13 +152,6 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
wrapper program around this command, provided for convenience.
</para>
<para>
There are security issues involved with using alternate database
locations specified with absolute path names; this is why the feature
is not enabled by default. See <xref
linkend="manage-ag-alternate-locs"> for more information.
</para>
<para>
Although it is possible to copy a database other than <literal>template1</>
by specifying its name as the template, this is not (yet) intended as
@@ -205,24 +169,6 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
<programlisting>
CREATE DATABASE lusiadas;
</programlisting>
</para>
<para>
To create a new database in an alternate area
<filename>~/private_db</filename>, execute the following from the
shell:
<programlisting>
mkdir private_db
initlocation ~/private_db
</programlisting>
Then execute the following from within a
<application>psql</application> session:
<programlisting>
CREATE DATABASE elsewhere WITH LOCATION '/home/olly/private_db';
</programlisting>
</para>
</refsect1>

View File

@@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_index.sgml,v 1.47 2004/04/20 12:53:28 momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_index.sgml,v 1.48 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation
-->
@@ -22,6 +22,7 @@ PostgreSQL documentation
<synopsis>
CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <replaceable class="parameter">table</replaceable> [ USING <replaceable class="parameter">method</replaceable> ]
( { <replaceable class="parameter">column</replaceable> | ( <replaceable class="parameter">expression</replaceable> ) } [ <replaceable class="parameter">opclass</replaceable> ] [, ...] )
[ TABLESPACE <replaceable class="parameter">tablespace</replaceable> ]
[ WHERE <replaceable class="parameter">predicate</replaceable> ]
</synopsis>
</refsynopsisdiv>
@@ -78,7 +79,7 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<para>
Indexes are not used for <literal>IS NULL</> clauses by default.
The best way to use indexes in such cases is to create a partial index
The best way to use indexes in such cases is to create a partial index
using an <literal>IS NULL</> comparison.
</para>
@@ -109,11 +110,11 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><literal>UNIQUE</literal></term>
<listitem>
<para>
Causes the system to check for
duplicate values in the table when the index is created (if data
already exist) and each time data is added. Attempts to
insert or update data which would result in duplicate entries
will generate an error.
Causes the system to check for
duplicate values in the table when the index is created (if data
already exist) and each time data is added. Attempts to
insert or update data which would result in duplicate entries
will generate an error.
</para>
</listitem>
</varlistentry>
@@ -122,9 +123,9 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><replaceable class="parameter">name</replaceable></term>
<listitem>
<para>
The name of the index to be created. No schema name can be included
here; the index is always created in the same schema as its parent
table.
The name of the index to be created. No schema name can be included
here; the index is always created in the same schema as its parent
table.
</para>
</listitem>
</varlistentry>
@@ -133,7 +134,7 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><replaceable class="parameter">table</replaceable></term>
<listitem>
<para>
The name (possibly schema-qualified) of the table to be indexed.
The name (possibly schema-qualified) of the table to be indexed.
</para>
</listitem>
</varlistentry>
@@ -154,7 +155,7 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><replaceable class="parameter">column</replaceable></term>
<listitem>
<para>
The name of a column of the table.
The name of a column of the table.
</para>
</listitem>
</varlistentry>
@@ -163,10 +164,10 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><replaceable class="parameter">expression</replaceable></term>
<listitem>
<para>
An expression based on one or more columns of the table. The
expression usually must be written with surrounding parentheses,
as shown in the syntax. However, the parentheses may be omitted
if the expression has the form of a function call.
An expression based on one or more columns of the table. The
expression usually must be written with surrounding parentheses,
as shown in the syntax. However, the parentheses may be omitted
if the expression has the form of a function call.
</para>
</listitem>
</varlistentry>
@@ -175,7 +176,17 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><replaceable class="parameter">opclass</replaceable></term>
<listitem>
<para>
The name of an operator class. See below for details.
The name of an operator class. See below for details.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">tablespace</replaceable></term>
<listitem>
<para>
The tablespace in which to create the index. If not specified,
the tablespace of the parent table is used.
</para>
</listitem>
</varlistentry>
@@ -184,10 +195,11 @@ CREATE [ UNIQUE ] INDEX <replaceable class="parameter">name</replaceable> ON <re
<term><replaceable class="parameter">predicate</replaceable></term>
<listitem>
<para>
The constraint expression for a partial index.
The constraint expression for a partial index.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
@@ -260,7 +272,7 @@ SELECT * FROM points
-->
</refsect1>
<refsect1>
<title>Compatibility</title>

View File

@@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_schema.sgml,v 1.11 2004/01/11 05:46:58 neilc Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_schema.sgml,v 1.12 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation
-->
@@ -12,7 +12,7 @@ PostgreSQL documentation
<refnamediv>
<refname>CREATE SCHEMA</refname>
<refpurpose>define a new schema</refpurpose>
</refnamediv>
</refnamediv>
<indexterm zone="sql-createschema">
<primary>CREATE SCHEMA</primary>
@@ -20,8 +20,8 @@ PostgreSQL documentation
<refsynopsisdiv>
<synopsis>
CREATE SCHEMA <replaceable class="parameter">schemaname</replaceable> [ AUTHORIZATION <replaceable class="parameter">username</replaceable> ] [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable> [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
CREATE SCHEMA <replaceable class="parameter">schemaname</replaceable> [ AUTHORIZATION <replaceable class="parameter">username</replaceable> ] [ TABLESPACE <replaceable class="parameter">tablespace</replaceable> ] [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable> [ TABLESPACE <replaceable class="parameter">tablespace</replaceable> ] [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
</synopsis>
</refsynopsisdiv>
@@ -54,7 +54,7 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable
all the created objects will be owned by that user.
</para>
</refsect1>
<refsect1>
<title>Parameters</title>
@@ -63,8 +63,8 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable
<term><replaceable class="parameter">schemaname</replaceable></term>
<listitem>
<para>
The name of a schema to be created. If this is omitted, the user name
is used as the schema name.
The name of a schema to be created. If this is omitted, the user name
is used as the schema name.
</para>
</listitem>
</varlistentry>
@@ -74,8 +74,19 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable
<listitem>
<para>
The name of the user who will own the schema. If omitted,
defaults to the user executing the command. Only superusers
may create schemas owned by users other than themselves.
defaults to the user executing the command. Only superusers
may create schemas owned by users other than themselves.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">tablespace</replaceable></term>
<listitem>
<para>
The name of the tablespace that is to be the default tablespace
for all new objects created in the schema. If not supplied, the schema
will inherit the default tablespace of the database.
</para>
</listitem>
</varlistentry>
@@ -102,8 +113,10 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable
<para>
To create a schema, the invoking user must have the
<literal>CREATE</> privilege for the current database. (Of course,
superusers bypass this check.)
<literal>CREATE</> privilege for the current database.
Also, the <literal>TABLESPACE</> option requires having
<literal>CREATE</> privilege for the specified tablespace.
(Of course, superusers bypass these checks.)
</para>
</refsect1>
@@ -181,7 +194,8 @@ CREATE VIEW hollywood.winners AS
<simplelist type="inline">
<member><xref linkend="sql-alterschema" endterm="sql-alterschema-title"></member>
<member><xref linkend="sql-dropschema" endterm="sql-dropschema-title"></member>
</simplelist>
<member><xref linkend="sql-createtablespace" endterm="sql-createtablespace-title"></member>
</simplelist>
</refsect1>
</refentry>

View File

@@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_sequence.sgml,v 1.39 2003/11/29 19:51:38 pgsql Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_sequence.sgml,v 1.40 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation
-->
@@ -12,7 +12,7 @@ PostgreSQL documentation
<refnamediv>
<refname>CREATE SEQUENCE</refname>
<refpurpose>define a new sequence generator</refpurpose>
</refnamediv>
</refnamediv>
<indexterm zone="sql-createsequence">
<primary>CREATE SEQUENCE</primary>
@@ -23,6 +23,7 @@ PostgreSQL documentation
CREATE [ TEMPORARY | TEMP ] 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 ]
[ START [ WITH ] <replaceable class="parameter">start</replaceable> ] [ CACHE <replaceable class="parameter">cache</replaceable> ] [ [ NO ] CYCLE ]
[ TABLESPACE <replaceable class="parameter">tablespace</replaceable> ]
</synopsis>
</refsynopsisdiv>
@@ -193,6 +194,19 @@ SELECT * FROM <replaceable>name</replaceable>;
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">tablespace</replaceable></term>
<listitem>
<para>
The optional clause <literal>TABLESPACE</> <replaceable
class="parameter">tablespace</replaceable> specifies
the tablespace in which to create the sequence. If this clause
is not supplied, the tablespace of the sequence's schema will be used.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
@@ -268,7 +282,7 @@ CREATE SEQUENCE serial START 101;
Select the next number from this sequence:
<programlisting>
SELECT nextval('serial');
nextval
---------
114

View File

@@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.81 2004/05/19 23:10:43 momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.82 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation
-->
@@ -28,6 +28,7 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable class="PAR
[ INHERITS ( <replaceable>parent_table</replaceable> [, ... ] ) ]
[ WITH OIDS | WITHOUT OIDS ]
[ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
[ TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable> ]
where <replaceable class="PARAMETER">column_constraint</replaceable> is:
@@ -48,7 +49,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
[ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ] }
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
</synopsis>
</refsynopsisdiv>
<refsect1 id="SQL-CREATETABLE-description">
@@ -321,7 +322,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>UNIQUE</> (column constraint)</term>
<term><literal>UNIQUE ( <replaceable class="PARAMETER">column_name</replaceable> [, ... ] )</> (table constraint)</term>
@@ -405,9 +406,9 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
<term><literal>REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> ) ] [ MATCH <replaceable class="parameter">matchtype</replaceable> ] [ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ]</literal> (column constraint)</term>
<term><literal>FOREIGN KEY ( <replaceable class="parameter">column</replaceable> [, ... ] )
REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> [, ... ] ) ]
REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> [, ... ] ) ]
[ MATCH <replaceable class="parameter">matchtype</replaceable> ]
[ ON DELETE <replaceable class="parameter">action</replaceable> ]
[ ON DELETE <replaceable class="parameter">action</replaceable> ]
[ ON UPDATE <replaceable class="parameter">action</replaceable> ]</literal>
(table constraint)</term>
@@ -514,7 +515,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>DEFERRABLE</literal></term>
<term><literal>NOT DEFERRABLE</literal></term>
@@ -553,7 +554,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
<listitem>
<para>
The behavior of temporary tables at the end of a transaction
block can be controlled using <literal>ON COMMIT</literal>.
block can be controlled using <literal>ON COMMIT</literal>.
The three options are:
<variablelist>
@@ -561,19 +562,19 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
<term><literal>PRESERVE ROWS</literal></term>
<listitem>
<para>
No special action is taken at the ends of transactions.
This is the default behavior.
No special action is taken at the ends of transactions.
This is the default behavior.
</para>
</listitem>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>DELETE ROWS</literal></term>
<listitem>
<para>
All rows in the temporary table will be deleted at the
end of each transaction block. Essentially, an automatic
<xref linkend="sql-truncate"> is done at each commit.
<xref linkend="sql-truncate"> is done at each commit.
</para>
</listitem>
</varlistentry>
@@ -583,7 +584,7 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
<listitem>
<para>
The temporary table will be dropped at the end of the current
transaction block.
transaction block.
</para>
</listitem>
</varlistentry>
@@ -591,8 +592,20 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> is:
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable></literal></term>
<listitem>
<para>
The <replaceable class="PARAMETER">tablespace</replaceable> is the name
of the tablespace in which the new table is to be created. If not
supplied, the default tablespace of the table's schema will be used.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
</refsect1>
<refsect1 id="SQL-CREATETABLE-notes">
<title>Notes</title>
@@ -696,7 +709,7 @@ CREATE TABLE films (
);
</programlisting>
</para>
<para>
Define a check column constraint:
@@ -719,7 +732,7 @@ CREATE TABLE distributors (
);
</programlisting>
</para>
<para>
Define a primary key table constraint for the table
<structname>films</>. Primary key table constraints can be defined
@@ -749,7 +762,7 @@ CREATE TABLE distributors (
did integer,
name varchar(40),
PRIMARY KEY(did)
);
);
</programlisting>
<programlisting>
@@ -812,7 +825,7 @@ CREATE TABLE distributors (
</para>
</refsect1>
<refsect1 id="SQL-CREATETABLE-compatibility">
<title id="SQL-CREATETABLE-compatibility-title">Compatibility</title>
@@ -827,7 +840,7 @@ CREATE TABLE distributors (
<para>
Although the syntax of <literal>CREATE TEMPORARY TABLE</literal>
resembles that of the SQL standard, the effect is not the same. In the
standard,
standard,
temporary tables are defined just once and automatically exist (starting
with empty contents) in every session that needs them.
<productname>PostgreSQL</productname> instead
@@ -889,7 +902,7 @@ CREATE TABLE distributors (
column, its presence is simply noise.
</para>
</refsect2>
<refsect2>
<title>Inheritance</title>
@@ -923,6 +936,15 @@ CREATE TABLE distributors (
DROP COLUMN</>, so it seems cleaner to ignore this spec restriction.
</para>
</refsect2>
<refsect2>
<title>TABLESPACE</title>
<para>
The <productname>PostgreSQL</productname> concept of tablespaces is not
standard.
</para>
</refsect2>
</refsect1>
@@ -932,6 +954,7 @@ CREATE TABLE distributors (
<simplelist type="inline">
<member><xref linkend="sql-altertable" endterm="sql-altertable-title"></member>
<member><xref linkend="sql-droptable" endterm="sql-droptable-title"></member>
<member><xref linkend="sql-createtablespace" endterm="sql-createtablespace-title"></member>
</simplelist>
</refsect1>
</refentry>

View File

@@ -0,0 +1,156 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_tablespace.sgml,v 1.1 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation
-->
<refentry id="SQL-CREATETABLESPACE">
<refmeta>
<refentrytitle id="sql-createtablespace-title">CREATE TABLESPACE</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>CREATE TABLESPACE</refname>
<refpurpose>define a new tablespace</refpurpose>
</refnamediv>
<indexterm zone="sql-createtablespace">
<primary>CREATE TABLESPACE</primary>
</indexterm>
<refsynopsisdiv>
<synopsis>
CREATE TABLESPACE <replaceable class="parameter">tablespacename</replaceable> [ OWNER <replaceable class="parameter">username</replaceable> ] LOCATION '<replaceable class="parameter">directory</replaceable>'
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>CREATE TABLESPACE</command> registers a new cluster-wide
tablespace. The tablespace name must be distinct from the name of any
existing tablespace in the database cluster.
</para>
<para>
A tablespace allows superusers to define an alternative location on the
file system where the data files representing database objects
(such as tables and indexes) may reside.
</para>
<para>
A user with appropriate privileges can pass
<replaceable class="parameter">tablespacename</> to <command>CREATE
DATABASE</>, <command>CREATE SCHEMA</>, <command>CREATE TABLE</>,
<command>CREATE INDEX</> or <command>CREATE SEQUENCE</> to have the data
files for these objects stored within the specified tablespace.
</para>
</refsect1>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term><replaceable class="parameter">tablespacename</replaceable></term>
<listitem>
<para>
The name of a tablespace to be created.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">username</replaceable></term>
<listitem>
<para>
The name of the user who will own the tablespace. If omitted,
defaults to the user executing the command. Only superusers
may create tablespaces, but they can assign ownership of tablespaces
to non-superusers.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">directory</replaceable></term>
<listitem>
<para>
The directory that will be used for the tablespace. The directory
must be empty and must be owned by the
<productname>PostgreSQL</> system user. The directory must be
specified by an absolute path name.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Notes</title>
<para>
Tablespaces are only supported on systems that support symbolic links.
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<para>
Create a tablespace <literal>dbspace</> at <literal>/data/dbs</>:
<programlisting>
CREATE TABLESPACE dbspace LOCATION '/data/dbs';
</programlisting>
</para>
<para>
Create a tablespace <literal>indexspace</> at <literal>/data/indexes</>
owned by user <literal>genevieve</>:
<programlisting>
CREATE TABLESPACE indexspace OWNER genevieve LOCATION '/data/indexes';
</programlisting>
</para>
</refsect1>
<refsect1>
<title>Compatibility</title>
<para>
<command>CREATE TABLESPACE</command> is a <productname>PostgreSQL</>
extension.
</para>
</refsect1>
<refsect1>
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="sql-createdatabase" endterm="sql-createdatabase-title"></member>
<member><xref linkend="sql-createschema" endterm="sql-createschema-title"></member>
<member><xref linkend="sql-createtable" endterm="sql-createtable-title"></member>
<member><xref linkend="sql-createindex" endterm="sql-createindex-title"></member>
<member><xref linkend="sql-createsequence" endterm="sql-createsequence-title"></member>
<member><xref linkend="sql-droptablespace" endterm="sql-droptablespace-title"></member>
</simplelist>
</refsect1>
</refentry>
<!-- 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:
-->

View File

@@ -0,0 +1,103 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/drop_tablespace.sgml,v 1.1 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation
-->
<refentry id="SQL-DROPTABLESPACE">
<refmeta>
<refentrytitle id="SQL-DROPTABLESPACE-TITLE">DROP TABLESPACE</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>DROP TABLESPACE</refname>
<refpurpose>remove a tablespace</refpurpose>
</refnamediv>
<indexterm zone="sql-droptablespace">
<primary>DROP TABLESPACE</primary>
</indexterm>
<refsynopsisdiv>
<synopsis>
DROP TABLESPACE <replaceable class="PARAMETER">tablespacename</replaceable>
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>DROP TABLESPACE</command> removes a tablespace from the system.
</para>
<para>
A tablespace can only be dropped by its owner or a superuser.
The tablespace must be empty of all database objects before it can be
dropped. It is possible that objects in other databases may still reside
in the tablespace even if no objects in the current database are using
the tablespace.
</para>
</refsect1>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term><replaceable class="PARAMETER">tablespacename</replaceable></term>
<listitem>
<para>
The name of a tablespace.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Examples</title>
<para>
To remove tablespace <literal>mystuff</literal> from the system:
<programlisting>
DROP TABLESPACE mystuff;
</programlisting>
</para>
</refsect1>
<refsect1>
<title>Compatibility</title>
<para>
<command>DROP TABLESPACE</command> is a <productname>PostgreSQL</>
extension.
</para>
</refsect1>
<refsect1>
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="sql-createtablespace" endterm="sql-createtablespace-title"></member>
</simplelist>
</refsect1>
</refentry>
<!-- 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:
-->

View File

@@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.40 2004/06/01 21:49:21 tgl Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.41 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation
-->
@@ -29,6 +29,10 @@ GRANT { { CREATE | TEMPORARY | TEMP } [,...] | ALL [ PRIVILEGES ] }
ON DATABASE <replaceable>dbname</replaceable> [, ...]
TO { <replaceable class="PARAMETER">username</replaceable> | GROUP <replaceable class="PARAMETER">groupname</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
GRANT { CREATE | ALL [ PRIVILEGES ] }
ON TABLESPACE <replaceable>tablespacename</> [, ...]
TO { <replaceable class="PARAMETER">username</replaceable> | GROUP <replaceable class="PARAMETER">groupname</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
GRANT { EXECUTE | ALL [ PRIVILEGES ] }
ON FUNCTION <replaceable>funcname</replaceable> ([<replaceable>type</replaceable>, ...]) [, ...]
TO { <replaceable class="PARAMETER">username</replaceable> | GROUP <replaceable class="PARAMETER">groupname</replaceable> | PUBLIC } [, ...] [ WITH GRANT OPTION ]
@@ -87,7 +91,7 @@ GRANT { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] }
<para>
Depending on the type of object, the initial default privileges may
include granting some privileges to <literal>PUBLIC</literal>.
The default is no public access for tables and schemas;
The default is no public access for tables, schemas, and tablespaces;
<literal>TEMP</> table creation privilege for databases;
<literal>EXECUTE</> privilege for functions; and
<literal>USAGE</> privilege for languages.
@@ -184,6 +188,12 @@ GRANT { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] }
<para>
For databases, allows new schemas to be created within the database.
</para>
<para>
For tablespaces, allows tables to be created within the tablespace,
and allows databases and schemas to be created that have the tablespace
as their default tablespace. (Note that revoking this privilege
will not alter the behavior of existing databases and schemas.)
</para>
<para>
For schemas, allows new objects to be created within the schema.
To rename an existing object, you must own the object <emphasis>and</>
@@ -223,7 +233,7 @@ GRANT { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] }
of privilege that is applicable to procedural languages.
</para>
<para>
For schemas, allows access to objects contained in the specified
For schemas, allows access to objects contained in the specified
schema (assuming that the objects' own privilege requirements are
also met). Essentially this allows the grantee to <quote>look up</>
objects within the schema.
@@ -385,7 +395,7 @@ GRANT ALL PRIVILEGES ON kinds TO manuel;
<refsect1 id="sql-grant-compatibility">
<title>Compatibility</title>
<para>
According to the SQL standard, the <literal>PRIVILEGES</literal>
key word in <literal>ALL PRIVILEGES</literal> is required. The
@@ -412,7 +422,7 @@ GRANT <replaceable class="PARAMETER">privileges</replaceable>
<para>
The <literal>RULE</literal> privilege, and privileges on
databases, schemas, languages, and sequences are
databases, tablespaces, schemas, languages, and sequences are
<productname>PostgreSQL</productname> extensions.
</para>
</refsect1>

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/revoke.sgml,v 1.30 2004/06/01 21:49:21 tgl Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/revoke.sgml,v 1.31 2004/06/18 06:13:05 tgl Exp $
PostgreSQL documentation
-->
@@ -33,6 +33,12 @@ REVOKE [ GRANT OPTION FOR ]
FROM { <replaceable class="PARAMETER">username</replaceable> | GROUP <replaceable class="PARAMETER">groupname</replaceable> | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ CREATE | ALL [ PRIVILEGES ] }
ON TABLESPACE <replaceable>tablespacename</replaceable> [, ...]
FROM { <replaceable class="PARAMETER">username</replaceable> | GROUP <replaceable class="PARAMETER">groupname</replaceable> | PUBLIC } [, ...]
[ CASCADE | RESTRICT ]
REVOKE [ GRANT OPTION FOR ]
{ EXECUTE | ALL [ PRIVILEGES ] }
ON FUNCTION <replaceable>funcname</replaceable> ([<replaceable>type</replaceable>, ...]) [, ...]

View File

@@ -1,5 +1,5 @@
<!-- reference.sgml
$PostgreSQL: pgsql/doc/src/sgml/reference.sgml,v 1.47 2004/04/20 01:14:55 momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/reference.sgml,v 1.48 2004/06/18 06:13:02 tgl Exp $
PostgreSQL Reference Manual
-->
@@ -76,6 +76,7 @@ PostgreSQL Reference Manual
&createSequence;
&createTable;
&createTableAs;
&createTableSpace;
&createTrigger;
&createType;
&createUser;
@@ -98,6 +99,7 @@ PostgreSQL Reference Manual
&dropSchema;
&dropSequence;
&dropTable;
&dropTableSpace;
&dropTrigger;
&dropType;
&dropUser;