PostgreSQL表空间

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

创建表时指定表空间
postgres=# create table test01(id int,note text) tablespace tbs_data ;
CREATE TABLE

创建索引时指定表空间
postgres=# create index idx_test01_id on test01 (id) tablespace tbs_data ;
CREATE INDEX

建唯一索引时指定约束索引的表空间
postgres=# alter table test01 add constraint unique_test01_id unique(id) using index tablespace tbs_data ;
ALTER TABLE
把表从一个表空间移动到另一个 表空间
postgres=# alter table test01 set tablespace pg_default ;
ALTER TABLE

原文地址:https://www.cnblogs.com/songyuejie/p/5026745.html