0

我有一个选择语句,它正在拉回数据库信息,例如名称、所有者、所有者的超级用户状态和表空间。对于低于 9.2 的 Postgresql 版本,我还能够提取表空间数据位置,但在 9.2 中,他们已将其更改为函数调用。我目前的查询是:

SELECT pg_database.datname as Database_Name, pg_authid.rolname as Database_Owner, 
pg_authid.rolsuper as IsSuperUser, pg_tablespace.spcname as TableSpaceName, 
pg_catalog.pg_tablespace_location(oid) as TableSpaceLocation
FROM pg_database
JOIN pg_authid on pg_database.datdba = pg_authid.oid
CROSS JOIN pg_tablespace
WHERE datistemplate = false
AND pg_database.dattablespace = pg_tablespace.oid;

其中函数调用是 SELECT 语句的最后一部分。但我收到一个错误:

ERROR:  column "oid" does not exist
LINE 3:     pg_catalog.pg_tablespace_location(oid) as TableSpaceLoca...

当我尝试运行它时,我不确定如何获取表空间位置作为此查询的一部分。如果我自己运行此功能:

SELECT pg_catalog.pg_tablespace_location(oid) as "Location"
FROM pg_catalog.pg_tablespace

我得到了正确的回应。有任何想法吗?

4

1 回答 1

1

请试试这个:

SELECT pg_database.datname as Database_Name, pg_authid.rolname as Database_Owner, 
pg_authid.rolsuper as IsSuperUser, pg_tablespace.spcname as TableSpaceName, 
pg_catalog.pg_tablespace_location(pg_tablespace.oid) as TableSpaceLocation
FROM pg_database
JOIN pg_authid on pg_database.datdba = pg_authid.oid
CROSS JOIN pg_tablespace
WHERE datistemplate = false
AND pg_database.dattablespace = pg_tablespace.oid;
于 2013-10-25T13:36:27.497 回答