PostgreSQL Use oid2name view the tables in the database

前端之家收集整理的这篇文章主要介绍了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

猜你在找的Postgre SQL相关文章