Skip to content

Commit a6949ca

Browse files
committed
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
1 parent fdba460 commit a6949ca

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

doc/src/sgml/ref/create_tablespace.sgml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ CREATE TABLESPACE <replaceable class="parameter">tablespace_name</replaceable>
9292
<listitem>
9393
<para>
9494
The directory that will be used for the tablespace. The directory
95-
should be empty and must be owned by the
95+
must exist (<command>CREATE TABLESPACE</command> will not create it),
96+
should be empty, and must be owned by the
9697
<productname>PostgreSQL</productname> system user. The directory must be
9798
specified by an absolute path name.
9899
</para>
@@ -137,15 +138,23 @@ CREATE TABLESPACE <replaceable class="parameter">tablespace_name</replaceable>
137138
<title>Examples</title>
138139

139140
<para>
140-
Create a tablespace <literal>dbspace</literal> at <literal>/data/dbs</literal>:
141+
To create a tablespace <literal>dbspace</literal> at file system location
142+
<literal>/data/dbs</literal>, first create the directory using operating
143+
system facilities and set the correct ownership:
144+
<programlisting>
145+
mkdir /data/dbs
146+
chown postgres:postgres /data/dbs
147+
</programlisting>
148+
Then issue the tablespace creation command inside
149+
<productname>PostgreSQL</productname>:
141150
<programlisting>
142151
CREATE TABLESPACE dbspace LOCATION '/data/dbs';
143152
</programlisting>
144153
</para>
145154

146155
<para>
147-
Create a tablespace <literal>indexspace</literal> at <literal>/data/indexes</literal>
148-
owned by user <literal>genevieve</literal>:
156+
To create a tablespace owned by a different database user, use a command
157+
like this:
149158
<programlisting>
150159
CREATE TABLESPACE indexspace OWNER genevieve LOCATION '/data/indexes';
151160
</programlisting></para>

0 commit comments

Comments
 (0)