CREATE TABLESPACE registers a new cluster-wide tablespace. The tablespace name must be distinct from the name of any existing tablespace in the database cluster.
A tablespace allows superusers to define an alternative location on the file system where the data files containing database objects (such as tables and indexes) can reside.
A user with appropriate privileges can pass tablespace_name to CREATE DATABASE, CREATE TABLE, CREATE INDEX or ADD CONSTRAINT to have the data files for these objects stored within the specified tablespace.
The name of a tablespace to be created. The name cannot begin with pg_, as such names are reserved for system tablespaces.
The name of the user who will own the tablespace. If omitted, defaults to the user executing the command. Only superusers can create tablespaces, but they can assign ownership of tablespaces to non-superusers.
The directory that will be used for the tablespace. The directory should be empty and must be owned by the PostgreSQL system user. The directory must be specified by an absolute path name.
Tablespaces are only supported on systems that support symbolic links.
CREATE TABLESPACE cannot be executed inside a transaction block.
Create a tablespace dbspace at /data/dbs:
CREATE TABLESPACE dbspace LOCATION '/data/dbs';
Create a tablespace indexspace at /data/indexes owned by user genevieve:
CREATE TABLESPACE indexspace OWNER genevieve LOCATION '/data/indexes';
On Windows platform, double back slashes are needed when specifying directory locations for tablespaces. Example: CREATE TABLESPACE mytablespace OWNER someowner LOCATION 'C:\\Program Files\\PostgreSQL\\9.3\\data\\mytablespace';
Please use this form to add your own comments regarding your experience with particular features of PostgreSQL, clarifications of the documentation, or hints for other users. Please note, this is not a support forum, and your IP address will be logged. If you have a question or need help, please see the faq, try a mailing list, or join us on IRC. Note that submissions containing URLs or other keywords commonly found in 'spam' comments may be silently discarded. Please contact the webmaster if you think this is happening to you in error.
Proceed to the comment form.