Re: How to find data directory

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Ken Hill <ken(at)scottshill(dot)com>
Cc: Jeff Frost <jeff(at)frostconsultingllc(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: How to find data directory
Date: 2005-12-19 01:04:36
Message-ID: 20051219010436.GA89158@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Sun, Dec 18, 2005 at 04:34:16PM -0800, Ken Hill wrote:
> That works nice. It shows my data directory in
> '/var/lib/postgresql/7.4/main'. When I do an ls command, I get:
>
> $ sudo ls /var/lib/postgresql/7.4/main
> base pg_clog pg_ident.conf pg_xlog postmaster.opts
> root.crt
> global pg_hba.conf PG_VERSION postgresql.conf postmaster.pid
>
> I have created two database named 'testdb' and 'csalgorithm'. How do I
> find these databases? I was expecting the databases to be subdirectories
> under the database directory (e.g. /var/lib/postresql/7.4/main/testdb
> and /var/lib/postgresql/7.4/main/csalgorithm).

Database directories are under the "base" directory with names that
match their oid in pg_database. So if pg_database has

SELECT oid, datname FROM pg_database;
oid | datname
-------+-----------
1 | template1
17141 | template0
(2 rows)

then the files for template1 will be under base/1 and the files for
template0 will be under base/17141.

In versions 8.0 and later you can control where database files go
by using tablespaces, and earlier versions had an "alternative
location" mechanism. See the "Managing Databases" chapter in the
documentation to learn about those features.

--
Michael Fuhr

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Peter Eisentraut 2005-12-19 01:06:20 Re: How to find data directory
Previous Message Devrim GUNDUZ 2005-12-19 01:01:01 Re: How to find data directory