CREATE TABLESPACE — define a new tablespace
CREATE TABLESPACEtablespace_name[ OWNER {new_owner| CURRENT_ROLE | CURRENT_USER | SESSION_USER } ] LOCATION 'template' [ WITH (tablespace_option=value[, ... ] ) ]
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.
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 to the actual
replication group id on each instance where statement is executed. The
directory name template must allow conversion an absolute path. The path
cannot contain new line characters. CREATE TABLESPACE
will 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 global boolean parameter. Creation of non-global
tablespaces is not allowed by default.
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);
CREATE TABLESPACE