postgres=# \h Create Tablespace
Command:create tablespace
Description:define a new tablespace
Syntax:
CREATE tablespace Tablespace_name
[OWNER User_name]
Location ' directory '
[With (tablespace_option = value [, ...])]
postgres=# Create tablespace tbs_data location '/opt/pg_tablespace ';
CREATE tablespace
postgres=# CREATE database db01 tablespace tbs_data;
CREATE DATABASE
postgres=# ALTER DATABASE DB01 set tablespace tbs_data;
ALTER DATABASE
Specify tablespace when creating tables
postgres=# CREATE TABLE test01 (ID int,note text) tablespace tbs_data;
CREATE TABLE
Specify tablespace when creating an index
postgres=# CREATE index idx_test01_id on test01 (ID) tablespace tbs_data;
CREATE INDEX
Table space specifying constrained indexes when building a unique index
postgres=# ALTER TABLE TEST01 add constraint unique_test01_id unique (ID) using index tablespace tbs_data;
ALTER TABLE
Move a table from one table space to another table space
postgres=# ALTER TABLE test01 set tablespace pg_default;
ALTER TABLE
PostgreSQL table Space