加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

PostgreSQL Use oid2name view the tables in the database

发布时间:2020-12-13 17:36:13 所属栏目:百科 来源:网络整理
导读:list help [postgres@zwc 16401]$ oid2name -hoid2name 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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读