Name oid2name -- resolve OIDs andfile nodes in a PostgreSQL data directory Synopsis oid2name [option...] Description 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 56.
[pg93@redhatB pg_tblspc]$ oid2name --help oid2name helps examining the file structure used by PostgreSQL. Usage: oid2name [OPTION]... Options: -d DBNAME database to connect to -f FILENODE show infofor table with given file node -H HOSTNAME database server host or socket directory -i show indexes and sequences too -o OID show infofor table with given OID -p PORT database server port number -q quiet (dont show headers) -s show all tablespaces -S show system objects too -t TABLE show infofor named table -U NAME connect as specified database user -V, --version output version information, then exit -x extended (show additional columns) -?, --help show this help, then exit The default action is to show all database OIDs. Report bugs to <pgsql-bugs@postgresql.org>.
Oid2name 使用
2.1 列出所有库
1 2 3 4 5 6 7 8 9
[pg93@redhatB pg_tblspc]$ oid2name All databases: Oid Database Name Tablespace ------------------------------------- 16386 francs tbs_francs 12895 postgres pg_default 16390 source_db tbs_source_db 12890 template0 pg_default 1 template1 pg_default
2.2 列出所有表空间
1 2 3 4 5 6 7 8
[pg93@redhatB pg_tblspc]$ oid2name -s All tablespaces: Oid Tablespace Name ------------------------ 1663 pg_default 1664 pg_global 16385 tbs_francs 16389 tbs_source_db
2.3 进入数据目录
1 2 3 4 5 6 7 8 9 10 11 12
[pg93@redhatB 16386]$ cd $PGDATA/pg_tblspc/16385 [pg93@redhatB 16385]$ cd PG_9.3_201305061/16386/ [pg93@redhatB 16386]$ ll | tail -n 8 -rw-------. 1 pg93 pg93 35M Jun 3 17:47 16702 -rw-------. 1 pg93 pg93 161M Jun 3 16:22 16703 -rw-------. 1 pg93 pg93 64K Jun 3 15:45 16703_fsm -rw-------. 1 pg93 pg93 8.0K Jun 3 16:14 16703_vm -rw-------. 1 pg93 pg93 35M Jun 3 15:45 16704 -rw-------. 1 pg93 pg93 512 May 15 10:30 pg_filenode.map -rw-------. 1 pg93 pg93 98K Jun 3 10:26 pg_internal.init -rw-------. 1 pg93 pg93 4 May 15 10:30 PG_VERSION
2.4 查看 16703 文件是什么
1 2 3 4 5
[pg93@redhatB 16386]$ oid2name -d francs -f 16703 From database "francs": Filenode Table Name ------------------------- 16703 test_not_full
2.5 显示更多信息
1 2 3 4 5
[pg93@redhatB 16386]$ oid2name -d francs -f 16703 -x From database "francs": Filenode Table Name Oid Schema Tablespace ---------------------------------------------------- 16703 test_not_full 16688 francs tbs_francs
2.6 根据 oid 查对表信息
1 2 3 4 5 6 7 8 9 10 11
[pg93@redhatB ~]$ psql francs francs -c "select oid,relname from pg_class where relname='test_1'"; oid | relname -------+--------- 16457 | test_1 (1 row) [pg93@redhatB ~]$ oid2name -d francs -o 16457 From database "francs": Filenode Table Name ---------------------- 16457 test_1