重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 687|回复: 1
打印 上一主题 下一主题

OPENGAUSS中表空间的默认路径

[复制链接]
跳转到指定楼层
楼主
发表于 2022-11-16 19:00:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
OPENGAUSS中表空间的默认路径

在openGauss中,表空间是一个目录,可以存在多个,里面存储的是它所包含的数据库的各种物理文件。由于表空间是一个目
录,仅是起到了物理隔离的作用,其管理功能依赖于文件系统。
openGauss的两个默认表空间:
pg_default,
pg_global

表空间pg_default:
   用来存储系统目录对象、用户表、用户表index、和临时表、临时表index、内部临时表的默认空间。
   对应存储目录 $PGDATA/base/

表空间pg_global:
   用来存放系统字典表;对应存储目录 $PGDATA/global


业务建立的表空间,放在 $PGDATA/pg_tblspc/ 通过OID去链接
下面是例子:绝对路劲
   openGauss=# create tablespace tsp_fee location '/tmp/tsp_fee01';
CREATE TABLESPACE

   openGauss=# \db
           List of tablespaces
    Name    |   Owner   |    Location   
------------+-----------+----------------
pg_default | opengauss |
pg_global  | opengauss |
tsp_fee    | opengauss | /tmp/tsp_fee01

openGauss=# select oid,* from pg_tablespace;
  oid  |  spcname   | spcowner | spcacl | spcoptions | spcmaxsize | relative
-------+------------+----------+--------+------------+------------+----------
  1663 | pg_default |       10 |        |            |            | f
  1664 | pg_global  |       10 |        |            |            | f
16385 | tsp_fee    |       10 |        |            |            | f
(3 rows)

select * from pg_tablespace_location((select oid from pg_tablespace where spcname='tsp_fee'));
pg_tablespace_location
------------------------
/tmp/tsp_fee01
(1 row)

  [opengauss@eulersvr pg_tblspc]$ echo $PGDATA
/var/lib/opengauss/data

[opengauss@eulersvr pg_tblspc]$ pwd
/var/lib/opengauss/data/pg_tblspc
[opengauss@eulersvr pg_tblspc]$
[opengauss@eulersvr pg_tblspc]$ ls -l
总用量 0
lrwxrwxrwx. 1 opengauss opengauss 14 11月 16 18:31 16385 -> /tmp/tsp_fee01
[opengauss@eulersvr pg_tblspc]$


--加相对路径:

postgres=# create tablespace tsp_fee relative location 'tablespace/tsp_fee01';
CREATE TABLESPACE

postgres=# select * from pg_tablespace_location((select oid from pg_tablespace where spcname='tsp_fee'));
pg_tablespace_location
------------------------
tablespace/tsp_fee01
(1 row)

postgres=# select oid,* from pg_tablespace;
  oid  |   spcname    | spcowner | spcacl | spcoptions | spcmaxsize | relative
-------+--------------+----------+--------+------------+------------+----------
  1663 | pg_default   |       10 |        |            |            | f
  1664 | pg_global    |       10 |        |            |            | f
16448 | tsp_fee      |       10 |        |            |            | t
(3 rows)



[omm@dbserver1 pg_tblspc]$ ls -l
total 0
lrwxrwxrwx 1 omm dbgrp 50 Nov 16 18:40 16448 -> /gaussdb/data/db1/pg_location/tablespace/tsp_fee01

放在 $PGDATA/pg_location/ 下面:

/gaussdb/data/db1/pg_location/tablespace

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

沙发
 楼主| 发表于 2022-11-16 19:04:14 | 只看该作者
查看表空间使用情况:
postgres=# SELECT PG_TABLESPACE_SIZE('tsp_fee');
pg_tablespace_size
--------------------
                  6
(1 row)
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-4-20 10:07 , Processed in 0.099819 second(s), 19 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表