Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/oid2name.sgml`
1adef083b9f3ea335154a38091597a58815c8601a041b5230000000100000be7
 <listitem><para>user name to connect as.</para></listitem>
    </varlistentry>

   </variablelist>
  </para>

  <para>
   To display specific tables, select which tables to show by
   using <option>-o</option>, <option>-f</option> and/or <option>-t</option>.
   <option>-o</option> takes an OID,
   <option>-f</option> takes a filenode,
   and <option>-t</option> takes a table name (actually, it's a <literal>LIKE</literal>
   pattern, so you can use things like <literal>foo%</literal>).
   You can use as many
   of these options as you like, and the listing will include all objects
   matched by any of the options.  But note that these options can only
   show objects in the database given by <option>-d</option>.
  </para>

  <para>
   If you don't give any of <option>-o</option>, <option>-f</option> or <option>-t</option>,
   but do give <option>-d</option>, it will list all tables in the database
   named by <option>-d</option>.  In this mode, the <option>-S</option> and
   <option>-i</option> options control what gets listed.
  </para>

  <para>
   If you don't give <option>-d</option> either, it will show a listing of database
   OIDs.  Alternatively you can give <option>-s</option> to get a tablespace
   listing.
  </para>
 </refsect1>

 <refsect1>
  <title>Environment</title>

  <variablelist>
   <varlistentry>
    <term><envar>PGHOST</envar></term>
    <term><envar>PGPORT</envar></term>
    <term><envar>PGUSER</envar></term>

    <listitem>
     <para>
      Default connection parameters.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>

  <para>
   This utility, like most other <productname>PostgreSQL</productname>
   utilities, also uses the environment variables supported by
   <application>libpq</application> (see <xref linkend="libpq-envars"/>).
  </para>

  <para>
   The environment variable <envar>PG_COLOR</envar> specifies whether to use
   color in diagnostic messages. Possible values are
   <literal>always</literal>, <literal>auto</literal> and
   <literal>never</literal>.
  </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

Title: oid2name Utility Environment and Usage
Summary
The oid2name utility uses environment variables such as PGHOST, PGPORT, and PGUSER to set default connection parameters, and also supports other libpq environment variables, with options to control output, including color and listing of databases, tablespaces, and objects, and is demonstrated with examples showing how to list databases, tablespaces, and objects, and how to navigate the database directory structure.