Advertisement
Advertisement


Where does PostgreSQL store the database?


Question

Where are the files for a PostgreSQL database stored?

2013/02/04
1
353
2/4/2013 9:07:15 PM


On Windows7 all the databases are referred by a number in the file named pg_database under C:\Program Files (x86)\PostgreSQL\8.2\data\global. Then you should search for the folder name by that number under C:\Program Files (x86)\PostgreSQL\8.2\data\base. That is the content of the database.

2016/06/23

Open pgAdmin and go to Properties for specific database. Find OID and then open directory

<POSTGRESQL_DIRECTORY>/data/base/<OID>

There should be your DB files.

2012/10/27

As suggested in "PostgreSQL database default location on Linux", under Linux you can find out using the following command:

ps aux | grep postgres | grep -- -D

Under my Linux installation, it's here: /var/lib/postgresql/8.x/

You can change it with initdb -D "c:/mydb/"

2017/12/08

The location of specific tables/indexes can be adjusted by TABLESPACEs:

CREATE TABLESPACE dbspace LOCATION '/data/dbs';
CREATE TABLE something (......) TABLESPACE dbspace;
CREATE TABLE otherthing (......) TABLESPACE dbspace;
2016/06/23

Source: https://stackoverflow.com/questions/1137060
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]