oid2name

A utility program which converts OIDs and filenodes in a data directory to human-readable values

oid2name is a utility program provided as a contrib module which converts OIDs and filenodes in a data directory to human-readable values. It requires a running and consistent database to operate (and is therefore not really useful as a forensic tool).

oid2name was introduced in PostgreSQL 7.1.

Change history

Examples

List databases:

$ oid2name -U postgres -d postgres -p 5432
All databases:
    Oid  Database Name  Tablespace
----------------------------------
  11788       postgres  pg_default
  16385           test  pg_default
  11787      template0  pg_default
      1      template1  pg_default

Create a table with differing OID and filenode:

postgres=# CREATE TABLE filenode_test (id INT);
CREATE TABLE

postgres=# SELECT oid, relfilenode FROM pg_class WHERE relname='filenode_test';
  oid  | relfilenode 
-------+-------------
 16453 |       16453
(1 row)

postgres=# VACUUM FULL filenode_test ;
VACUUM

postgres=# SELECT oid, relfilenode FROM pg_class WHERE relname='filenode_test';
  oid  | relfilenode 
-------+-------------
 16453 |       16456
(1 row)

Use oid2name to extract the table name from OID (option -o) and/or filenode (option -f):

$ oid2name -U postgres -d postgres -p 5432 -o 16453
From database "postgres":
  Filenode     Table Name
-------------------------
     16456  filenode_test

$ oid2name -U postgres -d postgres -p 5432 -f 16456
From database "postgres":
  Filenode     Table Name
-------------------------
     16456  filenode_test

Display additional details with the -x option:

$ oid2name -U postgres -d postgres -p 5432 -o 16453 -x
From database "postgres":
  Filenode     Table Name    Oid  Schema  Tablespace
----------------------------------------------------
     16456  filenode_test  16453  public  pg_default

The PostgreSQL documentation contains some further useful examples, including shell commands to operate on a selection of filenames taken from a data directory.

Categories

Contrib module, PostgreSQL internals, Storage, Utility program

See also

OID, filenode