pg_relation_filepath()

A function for obtaining the filepath of a relation

pg_relation_filepath() is a system function for obtaining the filepath of a relation, relative to the data directory.

pg_relation_filepath() was added in PostgreSQL 9.0.

Usage

pg_relation_filepath ( relation regclass ) → text

An ERROR is raised if the provided relation does not exist. This can also mean the relation is not visible in the current search path.

Change history

Examples

Basic usage example for pg_relation_filepath():

postgres=# SELECT pg_relation_filepath('foo');
 pg_relation_filepath 
----------------------
 base/13832/16499
(1 row)

Attempting to query the filepath of a non-existent relation:

postgres=# SELECT pg_relation_filepath('bar');
ERROR:  relation "bar" does not exist
LINE 1: SELECT pg_relation_filepath('bar');

See filenode for further examples.

Categories

Data directory, System function

See also

pg_relation_filenode(), pg_filenode_relation()