oid2name — resolve OIDs and file nodes in a PostgreSQL data directory
oid2name
[option
...]
oid2name is a utility program that helps administrators to examine the file structure used by PostgreSQL. To make use of it, you need to be familiar with the database file structure, which is described in Chapter 68.
The name “oid2name” is historical, and is actually rather misleading, since most of the time when you use it, you will really be concerned with tables' filenode numbers (which are the file names visible in the database directories). Be sure you understand the difference between table OIDs and table filenodes!
oid2name connects to a target database and extracts OID, filenode, and/or table name information. You can also have it show database OIDs or tablespace OIDs.
oid2name accepts the following command-line arguments:
-f
filenode
--filenode=
filenode
show info for table with filenode filenode
.
-i
--indexes
include indexes and sequences in the listing.
-o
oid
--oid=
oid
show info for table with OID oid
.
-q
--quiet
omit headers (useful for scripting).
-s
--tablespaces
show tablespace OIDs.
-S
--system-objects
include system objects (those in information_schema
, pg_toast
and pg_catalog
schemas).
-t
tablename_pattern
--table=
tablename_pattern
show info for table(s) matching tablename_pattern
.
-V
--version
Print the oid2name version and exit.
-x
--extended
display more information about each object shown: tablespace name, schema name, and OID.
-?
--help
Show help about oid2name command line arguments, and exit.
oid2name also accepts the following command-line arguments for connection parameters:
-d
database
--dbname=
database
database to connect to.
-h
host
--host=
host
database server's host.
-H
host
database server's host. Use of this parameter is deprecated as of PostgreSQL 12.
-p
port
--port=
port
database server's port.
-U
username
--username=
username
user name to connect as.
To display specific tables, select which tables to show by using -o
, -f
and/or -t
. -o
takes an OID, -f
takes a filenode, and -t
takes a table name (actually, it's a LIKE
pattern, so you can use things like foo%
). 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 -d
.
If you don't give any of -o
, -f
or -t
, but do give -d
, it will list all tables in the database named by -d
. In this mode, the -S
and -i
options control what gets listed.
If you don't give -d
either, it will show a listing of database OIDs. Alternatively you can give -s
to get a tablespace listing.
PGHOST
PGPORT
PGUSER
Default connection parameters.
This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 33.14).
oid2name requires a running database server with non-corrupt system catalogs. It is therefore of only limited use for recovering from catastrophic database corruption situations.
B. Palmer <
bpalmer@crimelabs.net
>