Commit a6949ca3 authored by Peter Eisentraut's avatar Peter Eisentraut

doc: Clarify CREATE TABLESPACE documentation

Be more specific about when and how to create the directory and what
permissions it should have.

Discussion: https://www.postgresql.org/message-id/flat/5ca60e1a-26f9-89fd-e912-021dd2b8afe2%40gmail.com
parent fdba460a
...@@ -92,7 +92,8 @@ CREATE TABLESPACE <replaceable class="parameter">tablespace_name</replaceable> ...@@ -92,7 +92,8 @@ CREATE TABLESPACE <replaceable class="parameter">tablespace_name</replaceable>
<listitem> <listitem>
<para> <para>
The directory that will be used for the tablespace. The directory The directory that will be used for the tablespace. The directory
should be empty and must be owned by the must exist (<command>CREATE TABLESPACE</command> will not create it),
should be empty, and must be owned by the
<productname>PostgreSQL</productname> system user. The directory must be <productname>PostgreSQL</productname> system user. The directory must be
specified by an absolute path name. specified by an absolute path name.
</para> </para>
...@@ -137,15 +138,23 @@ CREATE TABLESPACE <replaceable class="parameter">tablespace_name</replaceable> ...@@ -137,15 +138,23 @@ CREATE TABLESPACE <replaceable class="parameter">tablespace_name</replaceable>
<title>Examples</title> <title>Examples</title>
<para> <para>
Create a tablespace <literal>dbspace</literal> at <literal>/data/dbs</literal>: To create a tablespace <literal>dbspace</literal> at file system location
<literal>/data/dbs</literal>, first create the directory using operating
system facilities and set the correct ownership:
<programlisting>
mkdir /data/dbs
chown postgres:postgres /data/dbs
</programlisting>
Then issue the tablespace creation command inside
<productname>PostgreSQL</productname>:
<programlisting> <programlisting>
CREATE TABLESPACE dbspace LOCATION '/data/dbs'; CREATE TABLESPACE dbspace LOCATION '/data/dbs';
</programlisting> </programlisting>
</para> </para>
<para> <para>
Create a tablespace <literal>indexspace</literal> at <literal>/data/indexes</literal> To create a tablespace owned by a different database user, use a command
owned by user <literal>genevieve</literal>: like this:
<programlisting> <programlisting>
CREATE TABLESPACE indexspace OWNER genevieve LOCATION '/data/indexes'; CREATE TABLESPACE indexspace OWNER genevieve LOCATION '/data/indexes';
</programlisting></para> </programlisting></para>
......
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