Monday, 28 May 2018

How to locate the directory that contains a database in PostgreSQL

First of all you need to locate the data directory in which the databases are stored. If you do not know where to find the data directory you can read my blog entry: How to locate the data or cluster directory in PostgreSQL

In the data directory you will find a base directory and in the base directory there is a single directory per database. A database's directory name will always be a number.

The query

will display the Object ID and a database name for every database in the cluster.


Every database is stored in a single directory in the .../data/base directory. The database's directory name is the same as the databases's Object ID.

For example: The postgres database is stored in the 12603 directory.




No comments:

Post a Comment