translating filenames into tablenames?

Started by Ed L.about 23 years ago4 messagesgeneral
Jump to latest
#1Ed L.
pggeneral@bluepolka.net

Could someone point me to the docs or remind me of the tool that
allows me to translate filenames under $PGDATA/base/ into the
corresponding DB object name? I know this is an FAQ, but I didn't
see it.

Thanks in advance.

#2Dmitry Tkach
dmitry@openratings.com
In reply to: Ed L. (#1)
Re: translating filenames into tablenames?

select relname from pg_class where oid = <filename_without_extension>

should do it...

I hope, it helps..

Dima

Ed L. wrote:

Show quoted text

Could someone point me to the docs or remind me of the tool that=20
allows me to translate filenames under $PGDATA/base/ into the=20
corresponding DB object name? I know this is an FAQ, but I didn't=20
see it.

Thanks in advance.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

#3Bruce Momjian
bruce@momjian.us
In reply to: Ed L. (#1)
Re: translating filenames into tablenames?

I think you want /contrib/oid2name.

---------------------------------------------------------------------------

Ed L. wrote:

Could someone point me to the docs or remind me of the tool that
allows me to translate filenames under $PGDATA/base/ into the
corresponding DB object name? I know this is an FAQ, but I didn't
see it.

Thanks in advance.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#4Medi Montaseri
medi.montaseri@intransa.com
In reply to: Bruce Momjian (#3)
Re: translating filenames into tablenames?

You can also write your own based on

The following that I call ols (oid ls)

----------------------------------- cut
----------------------------------------
#!/bin/bash

DIR=$1

cd $DIR
for file in `ls -S`
do
psql -qc "select relid,relname from pg_stat_all_tables where
relid=$file" | grep $file
done

----------------------------------- cut again
--------------------------------------

yes, it could be optimized...

Bruce Momjian wrote:

Show quoted text

I think you want /contrib/oid2name.

---------------------------------------------------------------------------

Ed L. wrote:

Could someone point me to the docs or remind me of the tool that
allows me to translate filenames under $PGDATA/base/ into the
corresponding DB object name? I know this is an FAQ, but I didn't
see it.

Thanks in advance.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster