]> begriffs open source - ai-pg/blob - full-docs/man1/oid2name.1
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man1 / oid2name.1
1 '\" t
2 .\"     Title: oid2name
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
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 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 oid2name \- resolve OIDs and file nodes in a PostgreSQL data directory
32 .SH "SYNOPSIS"
33 .HP \w'\fBoid2name\fR\ 'u
34 \fBoid2name\fR [\fIoption\fR...]
35 .SH "DESCRIPTION"
36 .PP
37 oid2name
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
39 Chapter\ \&66\&.
40 .if n \{\
41 .sp
42 .\}
43 .RS 4
44 .it 1 an-trap
45 .nr an-no-space-flag 1
46 .nr an-break-flag 1
47 .br
48 .ps +1
49 \fBNote\fR
50 .ps -1
51 .br
52 .PP
53 The name
54 \(lqoid2name\(rq
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!
56 .sp .5v
57 .RE
58 .PP
59 oid2name
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\&.
61 .SH "OPTIONS"
62 .PP
63 oid2name
64 accepts the following command\-line arguments:
65 .PP
66 \fB\-f \fR\fB\fIfilenode\fR\fR
67 .br
68 \fB\-\-filenode=\fR\fB\fIfilenode\fR\fR
69 .RS 4
70 show info for table with filenode
71 \fIfilenode\fR\&.
72 .RE
73 .PP
74 \fB\-i\fR
75 .br
76 \fB\-\-indexes\fR
77 .RS 4
78 include indexes and sequences in the listing\&.
79 .RE
80 .PP
81 \fB\-o \fR\fB\fIoid\fR\fR
82 .br
83 \fB\-\-oid=\fR\fB\fIoid\fR\fR
84 .RS 4
85 show info for table with OID
86 \fIoid\fR\&.
87 .RE
88 .PP
89 \fB\-q\fR
90 .br
91 \fB\-\-quiet\fR
92 .RS 4
93 omit headers (useful for scripting)\&.
94 .RE
95 .PP
96 \fB\-s\fR
97 .br
98 \fB\-\-tablespaces\fR
99 .RS 4
100 show tablespace OIDs\&.
101 .RE
102 .PP
103 \fB\-S\fR
104 .br
105 \fB\-\-system\-objects\fR
106 .RS 4
107 include system objects (those in
108 \fBinformation_schema\fR,
109 \fBpg_toast\fR
110 and
111 \fBpg_catalog\fR
112 schemas)\&.
113 .RE
114 .PP
115 \fB\-t \fR\fB\fItablename_pattern\fR\fR
116 .br
117 \fB\-\-table=\fR\fB\fItablename_pattern\fR\fR
118 .RS 4
119 show info for table(s) matching
120 \fItablename_pattern\fR\&.
121 .RE
122 .PP
123 \fB\-V\fR
124 .br
125 \fB\-\-version\fR
126 .RS 4
127 Print the
128 oid2name
129 version and exit\&.
130 .RE
131 .PP
132 \fB\-x\fR
133 .br
134 \fB\-\-extended\fR
135 .RS 4
136 display more information about each object shown: tablespace name, schema name, and OID\&.
137 .RE
138 .PP
139 \fB\-?\fR
140 .br
141 \fB\-\-help\fR
142 .RS 4
143 Show help about
144 oid2name
145 command line arguments, and exit\&.
146 .RE
147 .PP
148 oid2name
149 also accepts the following command\-line arguments for connection parameters:
150 .PP
151 \fB\-d \fR\fB\fIdatabase\fR\fR
152 .br
153 \fB\-\-dbname=\fR\fB\fIdatabase\fR\fR
154 .RS 4
155 database to connect to\&.
156 .RE
157 .PP
158 \fB\-h \fR\fB\fIhost\fR\fR
159 .br
160 \fB\-\-host=\fR\fB\fIhost\fR\fR
161 .RS 4
162 database server\*(Aqs host\&.
163 .RE
164 .PP
165 \fB\-H \fR\fB\fIhost\fR\fR
166 .RS 4
167 database server\*(Aqs host\&. Use of this parameter is
168 \fIdeprecated\fR
169 as of
170 PostgreSQL
171 12\&.
172 .RE
173 .PP
174 \fB\-p \fR\fB\fIport\fR\fR
175 .br
176 \fB\-\-port=\fR\fB\fIport\fR\fR
177 .RS 4
178 database server\*(Aqs port\&.
179 .RE
180 .PP
181 \fB\-U \fR\fB\fIusername\fR\fR
182 .br
183 \fB\-\-username=\fR\fB\fIusername\fR\fR
184 .RS 4
185 user name to connect as\&.
186 .RE
187 .PP
188 To display specific tables, select which tables to show by using
189 \fB\-o\fR,
190 \fB\-f\fR
191 and/or
192 \fB\-t\fR\&.
193 \fB\-o\fR
194 takes an OID,
195 \fB\-f\fR
196 takes a filenode, and
197 \fB\-t\fR
198 takes a table name (actually, it\*(Aqs a
199 LIKE
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
202 \fB\-d\fR\&.
203 .PP
204 If you don\*(Aqt give any of
205 \fB\-o\fR,
206 \fB\-f\fR
207 or
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
211 \fB\-S\fR
212 and
213 \fB\-i\fR
214 options control what gets listed\&.
215 .PP
216 If you don\*(Aqt give
217 \fB\-d\fR
218 either, it will show a listing of database OIDs\&. Alternatively you can give
219 \fB\-s\fR
220 to get a tablespace listing\&.
221 .SH "ENVIRONMENT"
222 .PP
223 \fBPGHOST\fR
224 .br
225 \fBPGPORT\fR
226 .br
227 \fBPGUSER\fR
228 .RS 4
229 Default connection parameters\&.
230 .RE
231 .PP
232 This utility, like most other
233 PostgreSQL
234 utilities, also uses the environment variables supported by
235 libpq
236 (see
237 Section\ \&32.15)\&.
238 .PP
239 The environment variable
240 \fBPG_COLOR\fR
241 specifies whether to use color in diagnostic messages\&. Possible values are
242 always,
243 auto
244 and
245 never\&.
246 .SH "NOTES"
247 .PP
248 oid2name
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\&.
250 .SH "EXAMPLES"
251 .sp
252 .if n \{\
253 .RS 4
254 .\}
255 .nf
256 $ # what\*(Aqs in this database server, anyway?
257 $ oid2name
258 All databases:
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
265
266 $ oid2name \-s
267 All tablespaces:
268      Oid  Tablespace Name
269 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
270     1663       pg_default
271     1664        pg_global
272   155151         fastdisk
273   155152          bigdisk
274
275 $ # OK, let\*(Aqs look into database alvherre
276 $ cd $PGDATA/base/17228
277
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
290
291 $ # What file is 155173?
292 $ oid2name \-d alvherre \-f 155173
293 From database "alvherre":
294   Filenode  Table Name
295 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
296     155173    accounts
297
298 $ # you can ask for more than one object
299 $ oid2name \-d alvherre \-f 155173 \-f 1155291
300 From database "alvherre":
301   Filenode     Table Name
302 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
303     155173       accounts
304    1155291  accounts_pkey
305
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
313
314 $ # show disk space for every db object
315 $ du [0\-9]* |
316 > while read SIZE FILENODE
317 > do
318 >   echo "$SIZE       `oid2name \-q \-d alvherre \-i \-f $FILENODE`"
319 > done
320 16            1155287  branches_pkey
321 16            1155289  tellers_pkey
322 17561            1155291  accounts_pkey
323 \&.\&.\&.
324
325 $ # same, but sort by size
326 $ du [0\-9]* | sort \-rn | while read SIZE FN
327 > do
328 >   echo "$SIZE   `oid2name \-q \-d alvherre \-f $FN`"
329 > done
330 133466             155173    accounts
331 17561            1155291  accounts_pkey
332 1177              16717  pg_proc_proname_args_nsp_index
333 \&.\&.\&.
334
335 $ # If you want to see what\*(Aqs in tablespaces, use the pg_tblspc directory
336 $ cd $PGDATA/pg_tblspc
337 $ oid2name \-s
338 All tablespaces:
339      Oid  Tablespace Name
340 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
341     1663       pg_default
342     1664        pg_global
343   155151         fastdisk
344   155152          bigdisk
345
346 $ # what databases have objects in tablespace "fastdisk"?
347 $ ls \-d 155151/*
348 155151/17228/  155151/PG_VERSION
349
350 $ # Oh, what was database 17228 again?
351 $ oid2name
352 All databases:
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
359
360 $ # Let\*(Aqs see what objects does this database have in the tablespace\&.
361 $ cd 155151/17228
362 $ ls \-l
363 total 0
364 \-rw\-\-\-\-\-\-\-  1 postgres postgres 0 sep 13 23:20 155156
365
366 $ # OK, this is a pretty small table \&.\&.\&. but which one is it?
367 $ oid2name \-d alvherre \-f 155156
368 From database "alvherre":
369   Filenode  Table Name
370 \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
371     155156         foo
372 .fi
373 .if n \{\
374 .RE
375 .\}
376 .SH "AUTHOR"
377 .PP
378 B\&. Palmer
379 <bpalmer@crimelabs\&.net>