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



我在 redhat 9.2 上使用 postgres 6

这应该很简单,但我在任何地方都找不到它。我正在寻找存储 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)

但是没有位置,有什么想法保存在哪里吗?

谢谢

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

您将从pg_tablespace获得oid tablespace,因此查询应该是

select spcname
      ,pg_tablespace_location(oid) 
from   pg_tablespace;

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

\db+

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

使用以下查询获取表空间名称表空间位置。

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

相关内容

最新更新