Thread: Where do my local data bases go?

Where do my local data bases go?

From
Kevin Goulding
Date:
Hello,

In pgAdmin III, I can create a new database by right-clicking on the "Databases" folder in the left panel then choosing "New Database".  I also can create data bases in the Terminal by using the code "createdb db1" that will show up in pgAdmin after I click refresh.

My question is -- how do I find where on my hard drive the newly created database ends up?  I have searched the names, with no luck.  Could it have to do with the OID number (what is an "OID")?  When I set up the server, I used "localhost" and socket "5432".

system: Mac OS X 10.6.8

Thanks,
Kevin


Re: Where do my local data bases go?

From
"Jean-Yves F. Barbier"
Date:
On Mon, 30 Jan 2012 01:26:07 -0700
Kevin Goulding <kevingoulding@gmail.com> wrote:

>
> My question is -- how do I find where on my hard drive the newly created
> database ends up?

In Linux, files are in:
/var/lib/postgresql/Pg_version_Nb/main/base/OID_of_DB
(don't know for OSX)

This is the default path for initiating a DB.

> I have searched the names, with no luck.  Could it have
> to do with the OID number

Yep.

> (what is an "OID")?

Pg internal (integer) that represent any object (internals, tables,
columns, etc).

Pg supplies an utilitary that pairs OID and DB real name:
/usr/lib/postgresql/9.1/bin/oid2name
if you need to often use it, make a symlink into /usr/local/bin.

JY
--
    ***
  *******
 *********
 ****** Confucious say: "Is stuffy inside fortune cookie."
  *******
    ***

Re: Where do my local data bases go?

From
Tom Lane
Date:
"Jean-Yves F. Barbier" <12ukwn@gmail.com> writes:
> On Mon, 30 Jan 2012 01:26:07 -0700
> Kevin Goulding <kevingoulding@gmail.com> wrote:
>> My question is -- how do I find where on my hard drive the newly created
>> database ends up?

> In Linux, files are in:
> /var/lib/postgresql/Pg_version_Nb/main/base/OID_of_DB

That's the case for some packagings of Postgres, but not all.  The more
traditional location is /var/lib/pgsql/data/base/DBOID/...

>> I have searched the names, with no luck.  Could it have
>> to do with the OID number

> Yep.

If you're interested in this sort of detail, you might find it useful
to read the "Database Physical Storage" chapter of the manual:
http://www.postgresql.org/docs/9.1/static/storage.html
(adjust link in the obvious way for whichever major version you're
running, as the details move around sometimes)

            regards, tom lane