CREATE TABLESPACE
CREATE TABLESPACE — define a new tablespace
Synopsis
CREATE TABLESPACEtablespace_name[ OWNER {new_owner| CURRENT_ROLE | CURRENT_USER | SESSION_USER } ] LOCATION 'template' [ WITH (tablespace_option=value[, ... ] ) ]
Description
Shardman extension of the CREATE TABLESPACE syntax enables creation of a new cluster-wide tablespace. All tablespaces in a Shardman cluster must be cluster-wide. The cluster-wide tablespace is created on each cluster node with the location derived from the template parameter.
Parameters
-
tablespace_name# The name of a tablespace to be created. The name cannot begin with
pg_as such names are reserved for system tablespaces. Also the name cannot contain new line characters.-
template# The directory name template that will be used for the tablespace. The template must include “{rgid}” substring, which will be translated into the actual replication group ID on each instance where a statement is executed. The directory name template must allow conversion to an absolute path. The path cannot contain new line characters.
CREATE TABLESPACEwill create the corresponding directory if it is missing. If the directory exists, it must be empty and must be owned by the PostgreSQL system user.-
tablespace_option# A tablespace parameter to be set or reset. The list of parameters must include
globalboolean parameter. Creation of non-global tablespaces is not allowed by default.
Examples
To create a tablespace dbspace under the file system location /data/dbs, first create the directory using operating system facilities on all nodes and set the correct ownership (or ensure that postgres user has permissions to create it):
mkdir /data/dbs chown postgres:postgres /data/dbs
Then issue the tablespace creation command inside PostgreSQL:
CREATE TABLESPACE dbspace LOCATION '/data/dbs/ts-{rgid}' WITH (global);
See Also
PostgreSQLCREATE TABLESPACE