zoukankan      html  css  js  c++  java
  • postgresql逻辑结构--表空间(四)

    一、创建表空间

    1、 语法:create tablespace tablespace_name [owner user_name] location 'directory'

    postgres=# create tablespace tbs_data location '/var/lib/pgsql/9.6/pgdata';
    CREATE TABLESPACE
    

      

    2、创建数据库时设置默认目录

    postgres=# create database db01 tablespace tbs_data;
    CREATE DATABASE
    

      

    3、改变一个数据库默认表空间

    postgres=# alter database db01 set tablespace tbs_data;
    ALTER DATABASE  

    操作时不能有人同时连接这个数据库,数据库中已有的表空间不会改变

    4、创建表的时候也可以指定表空间。

    postgres=# create table test04(id int,note text) tablespace tbs_data;
    CREATE TABLE
    

      

    5 、创建索引的时候指定表空间

    postgres=# create index idx_test01_id on test04(id) tablespace tbs_data;
    CREATE INDEX
    

      

    6、创建唯一约束指定约束索引的表空间

    postgres=# alter table test04 add constraint unique_test04_id unique(id) using index tablespace tbs_data;
    ALTER TABLE
    

      

    7、增加主键时也可以指定主键索引的表空间

    postgres=# alter table test04 add constraint pk_test04_id primary key(id) using index tablespace tbs_data;
    ALTER TABLE
    

      

  • 相关阅读:
    2020/10/29
    2020/10/24
    2020/10/28
    2020/10/31周报
    linux shell 中判断字符串为空的正确方法
    20201107 千锤百炼软工人
    20201103 千锤百炼软工人
    20201109 千锤百炼软工人
    20201111 千锤百炼软工人
    20201105 千锤百炼软工人
  • 原文地址:https://www.cnblogs.com/sunshine-long/p/9052116.html
Copyright © 2011-2022 走看看