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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35221850/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:09:56  来源:igfitidea点击:

Where in the DB is the Location of a postgres tablespace stored

postgresqlpostgresql-9.2tablespace

提问by davegreen100

I am using postgres 9.2 on redhat 6

我在 redhat 6 上使用 postgres 9.2

this should be simple but I can't find it anywhere. I am looking for the database table and column which stores the Location for a postgres tablespace, I thought it would be in PG_TABLESPACE, but

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

select * from pg_tablespace

shows...

显示...

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

but no location, any ideas where the location is kept?

但没有位置,有什么想法可以保留位置吗?

thanks

谢谢

回答by Vivek S.

Use pg_tablespace_location(tablespace_oid)(PostgreSQL 9.2+) to get the path in the file system where the tablespaceis located.

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

You'll get oidof tablespacefrom pg_tablespace, so the query should be

你会得到oidtablespacepg_tablespace,所以查询应该是

select spcname
      ,pg_tablespace_location(oid) 
from   pg_tablespace;

回答by Srikant Patra

Use below query to get tablespace name tablespace location.

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

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