Home Explore Blog CI



postgresql

4th chunk of `doc/src/sgml/oid2name.sgml`
46869592dad46296d75576221db52572929a269eccf45fd700000001000007e6
 </para>
 </refsect1>

 <refsect1>
  <title>Notes</title>

  <para>
   <application>oid2name</application> requires a running database server with
   non-corrupt system catalogs.  It is therefore of only limited use
   for recovering from catastrophic database corruption situations.
  </para>
 </refsect1>

 <refsect1>
  <title>Examples</title>

<screen>
$ # what's in this database server, anyway?
$ oid2name
All databases:
    Oid  Database Name  Tablespace
----------------------------------
  17228       alvherre  pg_default
  17255     regression  pg_default
  17227      template0  pg_default
      1      template1  pg_default

$ oid2name -s
All tablespaces:
     Oid  Tablespace Name
-------------------------
    1663       pg_default
    1664        pg_global
  155151         fastdisk
  155152          bigdisk

$ # OK, let's look into database alvherre
$ cd $PGDATA/base/17228

$ # get top 10 db objects in the default tablespace, ordered by size
$ ls -lS * | head -10
-rw-------  1 alvherre alvherre 136536064 sep 14 09:51 155173
-rw-------  1 alvherre alvherre  17965056 sep 14 09:51 1155291
-rw-------  1 alvherre alvherre   1204224 sep 14 09:51 16717
-rw-------  1 alvherre alvherre    581632 sep  6 17:51 1255
-rw-------  1 alvherre alvherre    237568 sep 14 09:50 16674
-rw-------  1 alvherre alvherre    212992 sep 14 09:51 1249
-rw-------  1 alvherre alvherre    204800 sep 14 09:51 16684
-rw-------  1 alvherre alvherre    196608 sep 14 09:50 16700
-rw-------  1 alvherre alvherre    163840 sep 14 09:50 16699
-rw-------  1 alvherre alvherre    122880 sep  6 17:51 16751

$ # What file is 155173?
$ oid2name -d alvherre -f 155173
From database "alvherre":
  Filenode  Table Name
----------------------
    155173    accounts

$ # you can ask for more than one object
$ oid2name -d alvherre -f 155173 -f 1155291
From database "alvherre":
  Filenode     Table Name
-------------------------
    155173       accounts
   1155291  accounts_pkey

$ # you can mix the options, and get more details with -x

Title: oid2name Utility Notes and Examples
Summary
The oid2name utility has limited use in recovering from database corruption and requires a running database server with non-corrupt system catalogs, with examples demonstrating how to list databases, tablespaces, and objects, and how to use options to retrieve specific information, such as file nodes, table names, and detailed output.