微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

postgresql oid2name解析数据目录文件

cd /usr/lib/postgresql/9.3/bin

./oid2name --help

oid2name helps examining the file structure used by Postgresql.


Usage:

oid2name [OPTION]...


Options:

-d dbnAME database to connect to

-f FILENODE show info for table with given file node

-H HOSTNAME database server host or socket directory

-i show indexes and sequences too

-o OID show info for table with given OID

-p PORT database server port number

-q quiet (don't show headers)

-s show all tablespaces

-S show system objects too

-t TABLE show info for 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.


使用

列出所有库

postgres@db1:/usr/lib/postgresql/9.3/bin$ ./oid2name

All databases:

Oid Database Name Tablespace

---------------------------------------

16387 a pg_default

16388 b pg_default

16389 c pg_default

16477 d pg_default

32700 empty-next-release pg_default

12042 postgres pg_default

12037 template0 pg_default

1 template1 pg_default


列出所有表空间

postgres@db1:/usr/lib/postgresql/9.3/bin$ ./oid2name -s

All tablespaces:

Oid Tablespace Name

-----------------------

1663 pg_default

1664 pg_global


进入数据目录

cd /var/lib/postgresql/9.3/main/base/12037

postgres@db1:~/9.3/main/base/12037$ ls -ltr | tail -n 8

-rw------- 1 postgres postgres 16384 Oct 31 15:28 11904

-rw------- 1 postgres postgres 24576 Oct 31 15:28 11886_fsm

-rw------- 1 postgres postgres 8192 Oct 31 15:28 11879

-rw------- 1 postgres postgres 0 Oct 31 15:28 11861

-rw------- 1 postgres postgres 8192 Oct 31 15:28 11857_vm

-rw------- 1 postgres postgres 8192 Oct 31 15:28 11827

-rw------- 1 postgres postgres 516096 Oct 31 15:28 11797

-rw------- 1 postgres postgres 8192 Oct 31 15:28 11791


查看11791的文件是什么

postgres@db1:~/9.3/main/base/12037$ cd -

/usr/lib/postgresql/9.3/bin

postgres@db1:/usr/lib/postgresql/9.3/bin$ ./oid2name -d a -f 11791

From database "a":

Filenode Table Name

-------------------------------------

11791 pg_user_mapping_oid_index

显示更多的信息

postgres@db1:/usr/lib/postgresql/9.3/bin$ ./oid2name -d a -f 11791 -x

From database "a":

Filenode Table Name Oid Schema Tablespace

------------------------------------------------------------------

11791 pg_user_mapping_oid_index 174 pg_catalog pg_default

根据 oid 查对表信息

postgres@db1:/usr/lib/postgresql/9.3/bin$ psql -d a -c "select oid,relname from pg_class where relname='pg_user_mapping_oid_index'"

oid | relname

-----+---------------------------

174 | pg_user_mapping_oid_index

(1 row)


postgres@db1:/usr/lib/postgresql/9.3/bin$ ./oid2name -d a -o 174

From database "a":

Filenode Table Name

-------------------------------------

11791 pg_user_mapping_oid_index

原文地址:https://www.jb51.cc/postgresql/195966.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐