pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Chuming Chen <chen@musc.edu>
Cc: pgsql-admin list <pgsql-admin@postgresql.org>
Subject: Re: correspondence between the numbered folder and actual database
Date: Fri, 10 Dec 2004 16:15:51 -0700
Message-ID: <20041210231551.GA61422@winnie.fuhr.org> (raw)
In-Reply-To: <41B6FCB7.8040100@musc.edu>
References: <41B6FCB7.8040100@musc.edu>

On Wed, Dec 08, 2004 at 08:08:07AM -0500, Chuming Chen wrote:

> Is there any way I can find the correspondence between  the numbered 
> folders under postgresql data/base and the actual database name or table 
> name?

You could use contrib/oid2name.  If you want to do it yourself,
look at the pg_database.oid and pg_class.relfilenode fields.  For
example, given a file $PGDATA/base/164531/183620, the database
database OID is 164531 and the table or index filenode is 183620.
Find out what database the object is in with the following query:

SELECT datname FROM pg_database WHERE oid = 164531;
 datname 
---------
 test

Connect to that database and issue the following query:

SELECT n.nspname, c.relname
FROM pg_class AS c JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE relfilenode = 183620;
 nspname | relname 
---------+---------
 public  | foo

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



view thread (2+ messages)

Message-ID: <20041210231551.GA61422@winnie.fuhr.org>
Permalink:  ../20041210231551.GA61422@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20041210231551.GA61422@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: mike@fuhr.org, chen@musc.edu
  Subject: Re: correspondence between the numbered folder and actual database
  In-Reply-To: <20041210231551.GA61422@winnie.fuhr.org>
  References: <41B6FCB7.8040100@musc.edu> <20041210231551.GA61422@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox