3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "OID2NAME" "1" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 oid2name \- resolve OIDs and file nodes in a PostgreSQL data directory
33 .HP \w'\fBoid2name\fR\ 'u
34 \fBoid2name\fR [\fIoption\fR...]
38 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
45 .nr an-no-space-flag 1
55 is historical, and is actually rather misleading, since most of the time when you use it, you will really be concerned with tables\*(Aq filenode numbers (which are the file names visible in the database directories)\&. Be sure you understand the difference between table OIDs and table filenodes!
60 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\&.
64 accepts the following command\-line arguments:
66 \fB\-f \fR\fB\fIfilenode\fR\fR
68 \fB\-\-filenode=\fR\fB\fIfilenode\fR\fR
70 show info for table with filenode
78 include indexes and sequences in the listing\&.
81 \fB\-o \fR\fB\fIoid\fR\fR
83 \fB\-\-oid=\fR\fB\fIoid\fR\fR
85 show info for table with OID
93 omit headers (useful for scripting)\&.
100 show tablespace OIDs\&.
105 \fB\-\-system\-objects\fR
107 include system objects (those in
108 \fBinformation_schema\fR,
115 \fB\-t \fR\fB\fItablename_pattern\fR\fR
117 \fB\-\-table=\fR\fB\fItablename_pattern\fR\fR
119 show info for table(s) matching
120 \fItablename_pattern\fR\&.
136 display more information about each object shown: tablespace name, schema name, and OID\&.
145 command line arguments, and exit\&.
149 also accepts the following command\-line arguments for connection parameters:
151 \fB\-d \fR\fB\fIdatabase\fR\fR
153 \fB\-\-dbname=\fR\fB\fIdatabase\fR\fR
155 database to connect to\&.
158 \fB\-h \fR\fB\fIhost\fR\fR
160 \fB\-\-host=\fR\fB\fIhost\fR\fR
162 database server\*(Aqs host\&.
165 \fB\-H \fR\fB\fIhost\fR\fR
167 database server\*(Aqs host\&. Use of this parameter is
174 \fB\-p \fR\fB\fIport\fR\fR
176 \fB\-\-port=\fR\fB\fIport\fR\fR
178 database server\*(Aqs port\&.
181 \fB\-U \fR\fB\fIusername\fR\fR
183 \fB\-\-username=\fR\fB\fIusername\fR\fR
185 user name to connect as\&.
188 To display specific tables, select which tables to show by using
196 takes a filenode, and
198 takes a table name (actually, it\*(Aqs a
200 pattern, so you can use things like
201 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
204 If you don\*(Aqt give any of
208 \fB\-t\fR, but do give
209 \fB\-d\fR, it will list all tables in the database named by
210 \fB\-d\fR\&. In this mode, the
214 options control what gets listed\&.
216 If you don\*(Aqt give
218 either, it will show a listing of database OIDs\&. Alternatively you can give
220 to get a tablespace listing\&.
229 Default connection parameters\&.
232 This utility, like most other
234 utilities, also uses the environment variables supported by
239 The environment variable
241 specifies whether to use color in diagnostic messages\&. Possible values are
249 requires a running database server with non\-corrupt system catalogs\&. It is therefore of only limited use for recovering from catastrophic database corruption situations\&.
256 $ # what\*(Aqs in this database server, anyway?
259 Oid Database Name Tablespace
260 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
261 17228 alvherre pg_default
262 17255 regression pg_default
263 17227 template0 pg_default
264 1 template1 pg_default
269 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
275 $ # OK, let\*(Aqs look into database alvherre
276 $ cd $PGDATA/base/17228
278 $ # get top 10 db objects in the default tablespace, ordered by size
279 $ ls \-lS * | head \-10
280 \-rw\-\-\-\-\-\-\- 1 alvherre alvherre 136536064 sep 14 09:51 155173
281 \-rw\-\-\-\-\-\-\- 1 alvherre alvherre 17965056 sep 14 09:51 1155291
282 \-rw\-\-\-\-\-\-\- 1 alvherre alvherre 1204224 sep 14 09:51 16717
283 \-rw\-\-\-\-\-\-\- 1 alvherre alvherre 581632 sep 6 17:51 1255
284 \-rw\-\-\-\-\-\-\- 1 alvherre alvherre 237568 sep 14 09:50 16674
285 \-rw\-\-\-\-\-\-\- 1 alvherre alvherre 212992 sep 14 09:51 1249
286 \-rw\-\-\-\-\-\-\- 1 alvherre alvherre 204800 sep 14 09:51 16684
287 \-rw\-\-\-\-\-\-\- 1 alvherre alvherre 196608 sep 14 09:50 16700
288 \-rw\-\-\-\-\-\-\- 1 alvherre alvherre 163840 sep 14 09:50 16699
289 \-rw\-\-\-\-\-\-\- 1 alvherre alvherre 122880 sep 6 17:51 16751
291 $ # What file is 155173?
292 $ oid2name \-d alvherre \-f 155173
293 From database "alvherre":
295 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
298 $ # you can ask for more than one object
299 $ oid2name \-d alvherre \-f 155173 \-f 1155291
300 From database "alvherre":
302 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
304 1155291 accounts_pkey
306 $ # you can mix the options, and get more details with \-x
307 $ oid2name \-d alvherre \-t accounts \-f 1155291 \-x
308 From database "alvherre":
309 Filenode Table Name Oid Schema Tablespace
310 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
311 155173 accounts 155173 public pg_default
312 1155291 accounts_pkey 1155291 public pg_default
314 $ # show disk space for every db object
316 > while read SIZE FILENODE
318 > echo "$SIZE `oid2name \-q \-d alvherre \-i \-f $FILENODE`"
320 16 1155287 branches_pkey
321 16 1155289 tellers_pkey
322 17561 1155291 accounts_pkey
325 $ # same, but sort by size
326 $ du [0\-9]* | sort \-rn | while read SIZE FN
328 > echo "$SIZE `oid2name \-q \-d alvherre \-f $FN`"
330 133466 155173 accounts
331 17561 1155291 accounts_pkey
332 1177 16717 pg_proc_proname_args_nsp_index
335 $ # If you want to see what\*(Aqs in tablespaces, use the pg_tblspc directory
336 $ cd $PGDATA/pg_tblspc
340 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
346 $ # what databases have objects in tablespace "fastdisk"?
348 155151/17228/ 155151/PG_VERSION
350 $ # Oh, what was database 17228 again?
353 Oid Database Name Tablespace
354 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
355 17228 alvherre pg_default
356 17255 regression pg_default
357 17227 template0 pg_default
358 1 template1 pg_default
360 $ # Let\*(Aqs see what objects does this database have in the tablespace\&.
364 \-rw\-\-\-\-\-\-\- 1 postgres postgres 0 sep 13 23:20 155156
366 $ # OK, this is a pretty small table \&.\&.\&. but which one is it?
367 $ oid2name \-d alvherre \-f 155156
368 From database "alvherre":
370 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
379 <bpalmer@crimelabs\&.net>