数据库中postgres表空间存储的位置

问题描述 投票:0回答:4

我在 redhat 6 上使用 postgres 9.2

这应该很简单,但我在任何地方都找不到它。我正在寻找存储 postgres 表空间位置的数据库表和列,我认为它会在 PG_TABLESPACE 中,但是

select * from pg_tablespace

显示...

postgres=# select * from pg_tablespace;
     spcname     | spcowner | spcacl | spcoptions
-----------------+----------+--------+------------
 pg_default      |       10 |        |
 pg_global       |       10 |        |
 C_TBL_DB91SABIR |       10 |        |
(3 rows)

但没有位置,有什么想法保存位置吗?

谢谢

postgresql postgresql-9.2 tablespace
4个回答
37
投票

使用

pg_tablespace_location(tablespace_oid)
(PostgreSQL 9.2+)获取
tablespace
所在文件系统的路径。

您将从

oid
得到
tablespace
pg_tablespace
,因此查询应该是

select spcname
      ,pg_tablespace_location(oid) 
from   pg_tablespace;

7
投票

另一个超级简单的命令来列出所有表空间

\db+

这将非常快速地为您提供所有表空间详细信息


0
投票

知道为什么 pg_default 和 pg_global 表空间位置在磁盘上不可见吗?我在这里找到了相关答案“PostgreSQL中的表空间位置”,但如果有人可以详细解释就会很容易理解。


-6
投票

使用下面的查询来获取表空间名称表空间位置。

postgres=# select spcname ,pg_tablespace_location(oid) from pg_tablespace;
  spcname   |    pg_tablespace_location     
------------+-------------------------------
 pg_default | 
 pg_global  | 
 fastspace  | /var/lib/postgresql/data/base
 demotbs    | /var/lib/postgresql/data
© www.soinside.com 2019 - 2024. All rights reserved.