PostgreSQL Use oid2name view the tables in the database

list help

[postgres@zwc 16401]$ oid2name -h
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.

Report bugs to <pgsql-bugs@postgresql.org>.


database tablespace

[postgres@zwc base]$ ls -l
total 28
drwx------ 2 postgres postgres 12288 Sep  2 10:13 1
drwx------ 2 postgres postgres  4096 Aug 28 12:56 12783
drwx------ 2 postgres postgres  4096 Sep  2 10:13 12788
drwx------ 2 postgres postgres  4096 Sep  2 10:13 16401
drwx------ 2 postgres postgres  4096 Aug 28 15:53 pgsql_tmp
[postgres@zwc base]$ psql
psql (9.2.4)
Type "help" for help.


postgres=# \d pg_database;
    Table "pg_catalog.pg_database"
    Column     |   Type    | Modifiers 
---------------+-----------+-----------
 datname       | name      | not null
 datdba        | oid       | not null
 encoding      | integer   | not null
 datcollate    | name      | not null
 datctype      | name      | not null
 datistemplate | boolean   | not null
 datallowconn  | boolean   | not null
 datconnlimit  | integer   | not null
 datlastsysoid | oid       | not null
 datfrozenxid  | xid       | not null
 dattablespace | oid       | not null
 datacl        | aclitem[] | 
Indexes:
    "pg_database_datname_index" UNIQUE, btree (datname), tablespace "pg_global"
    "pg_database_oid_index" UNIQUE, btree (oid), tablespace "pg_global"
Tablespace: "pg_global"


postgres=# 
postgres=# select datname,oid from pg_database;
  datname  |  oid  
-----------+-------
 template1 |     1
 template0 | 12783
 postgres  | 12788
 testdb    | 16401
(4 rows)


Use oid2name

[postgres@zwc base]$ oid2name
All databases:
    Oid  Database Name  Tablespace
----------------------------------
  12788       postgres  pg_default
  12783      template0  pg_default
      1      template1  pg_default
  16401         testdb  pg_default

[postgres@zwc 16401]$ oid2name -d testdb -f 12533
From database "testdb":
  Filenode         Table Name
-----------------------------
     12533  pg_type_oid_index
[postgres@zwc 16401]$ oid2name -d testdb -f 12533 -x
From database "testdb":
  Filenode         Table Name   Oid      Schema  Tablespace
-----------------------------------------------------------
     12533  pg_type_oid_index  2703  pg_catalog  pg_default

[postgres@zwc 16401]$ oid2name -d testdb
From database "testdb":
  Filenode  Table Name
----------------------
     16404   orderinfo
[postgres@zwc 16401]$ oid2name -d testdb -f 16404
From database "testdb":
  Filenode  Table Name
----------------------
     16404   orderinfo
[postgres@zwc 16401]$ oid2name -d testdb -f 16404 -x
From database "testdb":
  Filenode  Table Name    Oid  Schema  Tablespace
-------------------------------------------------
     16404   orderinfo  16404  public  pg_default


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值