3 PostgreSQL documentation
6 <refentry id=
"SQL-CREATETABLESPACE">
8 <refentrytitle id=
"sql-createtablespace-title">CREATE TABLESPACE
</refentrytitle>
9 <manvolnum>7</manvolnum>
10 <refmiscinfo>SQL - Language Statements
</refmiscinfo>
14 <refname>CREATE TABLESPACE
</refname>
15 <refpurpose>define a new tablespace
</refpurpose>
18 <indexterm zone=
"sql-createtablespace">
19 <primary>CREATE TABLESPACE
</primary>
24 CREATE TABLESPACE
<replaceable class=
"parameter">tablespacename
</replaceable> [ OWNER
<replaceable class=
"parameter">username
</replaceable> ] LOCATION '
<replaceable class=
"parameter">directory
</replaceable>'
29 <title>Description
</title>
32 <command>CREATE TABLESPACE
</command> registers a new cluster-wide
33 tablespace. The tablespace name must be distinct from the name of any
34 existing tablespace in the database cluster.
38 A tablespace allows superusers to define an alternative location on
39 the file system where the data files containing database objects
40 (such as tables and indexes) can reside.
44 A user with appropriate privileges can pass
45 <replaceable class=
"parameter">tablespacename<
/> to
46 <command>CREATE DATABASE<
/>,
<command>CREATE TABLE<
/>,
47 <command>CREATE INDEX<
/> or
<command>ADD CONSTRAINT<
/> to have the data
48 files for these objects stored within the specified tablespace.
53 <title>Parameters
</title>
57 <term><replaceable class=
"parameter">tablespacename
</replaceable></term>
60 The name of a tablespace to be created. The name cannot
61 begin with
<literal>pg_
</literal>, as such names
62 are reserved for system tablespaces.
68 <term><replaceable class=
"parameter">username
</replaceable></term>
71 The name of the user who will own the tablespace. If omitted,
72 defaults to the user executing the command. Only superusers
73 can create tablespaces, but they can assign ownership of tablespaces
80 <term><replaceable class=
"parameter">directory
</replaceable></term>
83 The directory that will be used for the tablespace. The directory
84 must be empty and must be owned by the
85 <productname>PostgreSQL<
/> system user. The directory must be
86 specified by an absolute path name.
97 Tablespaces are only supported on systems that support symbolic links.
101 <command>CREATE TABLESPACE<
/> cannot be executed inside a transaction
107 <title>Examples
</title>
110 Create a tablespace
<literal>dbspace<
/> at
<literal>/data/dbs<
/>:
112 CREATE TABLESPACE dbspace LOCATION '/data/dbs';
117 Create a tablespace
<literal>indexspace<
/> at
<literal>/data/indexes<
/>
118 owned by user
<literal>genevieve<
/>:
120 CREATE TABLESPACE indexspace OWNER genevieve LOCATION '/data/indexes';
126 <title>Compatibility
</title>
129 <command>CREATE TABLESPACE
</command> is a
<productname>PostgreSQL<
/>
135 <title>See Also
</title>
137 <simplelist type=
"inline">
138 <member><xref linkend=
"sql-createdatabase" endterm=
"sql-createdatabase-title"></member>
139 <member><xref linkend=
"sql-createtable" endterm=
"sql-createtable-title"></member>
140 <member><xref linkend=
"sql-createindex" endterm=
"sql-createindex-title"></member>
141 <member><xref linkend=
"sql-droptablespace" endterm=
"sql-droptablespace-title"></member>
142 <member><xref linkend=
"sql-altertablespace" endterm=
"sql-altertablespace-title"></member>