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

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 @R_509_4045@ion,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>.

@H_404_12@

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)
@H_404_12@ @H_404_12@

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
@H_404_12@
[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
@H_404_12@
[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

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

相关推荐