pg_relation_filepath() 是一个系统函数,用于获取关系(relation)相对于数据目录的文件路径。
pg_relation_filepath() 函数在 PostgreSQL 9.0 中被添加。
用法
pg_relation_filepath (relationregclass) →text
如果提供的关系不存在,则会引发一个 ERROR。这也可能意味着该关系在当前搜索路径中不可见。
变更历史
- PostgreSQL 9.0
- 添加于 (提交 b9b8831a)
示例
pg_relation_filepath() 的基本用法示例
postgres=# SELECT pg_relation_filepath('foo');
pg_relation_filepath
----------------------
base/13832/16499
(1 row)
尝试查询不存在的关系的文件路径
postgres=# SELECT pg_relation_filepath('bar');
ERROR: relation "bar" does not exist
LINE 1: SELECT pg_relation_filepath('bar');
更多示例请参见 filenode。
参考资料
- PostgreSQL 文档: 数据库对象位置函数
