PostgreSQL table Space

Source: Internet
Author: User
Tags create index

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.