PostgreSQL:表空间-->数据库-->表

1、表空间:

可以通过表空间指定不同性能的存储上:

[root@jason1 ~]# mkdir -p /ssd/tbs_jason01

[root@jason1 ~]# chown -R postgres:postgres /ssd/tbs_jason01

[root@jason1 ~]# cd /ssd/tbs_jason01


postgres=# create tablespace tbs_jason01 LOCATION '/ssd/tbs_jason01';

CREATE TABLESPACE


#每个表空间对应一个目录

[root@jason1 tbs_jason01]# ll

total 0

drwx------. 2 postgres postgres 6 Sep 24 21:22 PG_10_201707211

[root@jason1 tbs_jason01]#


2、表空间目录下,每个库对应一个目录

postgres=# create database jason01 tablespace tbs_jason01;

CREATE DATABASE

postgres=# select oid,datname from pg_database;

  oid  |  datname 

-------+-----------

13212 | postgres

16384 | test

     1 | template1

13211 | template0

16385 | jason

16389 | jason01

(6 rows)


[root@jason1 PG_10_201707211]# ll

total 12

drwx------. 2 postgres postgres 8192 Sep 24 21:25 16389


3、在数据库中,每个表对应一个个文件 ,以每个文件1G的形式存储,单表最大支持量 32T。

postgres=# \c jason01

You are now connected to database "jason01" as user "postgres".

jason01=#

jason01=# create table jason01(

jason01(#     id int,

jason01(#     note text

jason01(# ) tablespace tbs_jason01;

CREATE TABLE

jason01=#


[root@jason1 16389]# pwd

/ssd/tbs_jason01/PG_10_201707211/16389

[root@jason1 16389]# ll -lrt

-rw-------. 1 postgres postgres  24576 Sep 24 21:25 13072_fsm

-rw-------. 1 postgres postgres   8192 Sep 24 21:25 13062_vm

-rw-------. 1 postgres postgres  24576 Sep 24 21:25 13062_fsm

-rw-------. 1 postgres postgres 136164 Sep 24 21:34 pg_internal.init

-rw-------. 1 postgres postgres      0 Sep 24 21:34 16408

-rw-------. 1 postgres postgres   8192 Sep 24 21:34 16413

-rw-------. 1 postgres postgres      0 Sep 24 21:34 16411

 


##查看表存储路径:

jason=# \c jason01

You are now connected to database "jason01" as user "postgres".

jason01=# select pg_relation_filepath('jason01');

            pg_relation_filepath            

---------------------------------------------

pg_tblspc/16388/PG_10_201707211/16389/16408

(1 row)


jason01=#


jason01=# insert into jason01 values(1,'dagagdgaaga');

INSERT 0 1


[root@jason1 16389]# ll 164*

-rw-------. 1 postgres postgres 8192 Sep 26 14:59 16408

-rw-------. 1 postgres postgres    0 Sep 24 21:34 16411

-rw-------. 1 postgres postgres 8192 Sep 24 21:34 16413



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27126919/viewspace-2214754/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/27126919/viewspace-2214754/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值