バージョンごとのドキュメント一覧

oid2name

oid2name <refpurpose>resolve OIDs and file nodes in a <productname>PostgreSQL</productname> data directory</refpurpose> — OIDとPostgreSQLデータディレクトリ内のファイルノードを解決する

概要

oid2name [option...]

説明

<title>Description</title>

<application>oid2name</application> is a utility program that helps administrators to examine the file structure used by PostgreSQL. To make use of it, you need to be familiar with the database file structure, which is described in <xref linkend="storage"/>. oid2nameは、管理者がPostgreSQLで使用されるファイル構造を確認することを補助するユーティリティプログラムです。 使用できるようになるためには、第73章で説明されるデータベースファイル構造についての知識が必要です。

注記

The name <quote>oid2name</quote> is historical, and is actually rather misleading, since most of the time when you use it, you will really be concerned with tables' filenode numbers (which are the file names visible in the database directories). Be sure you understand the difference between table OIDs and table filenodes! oid2nameという名前は歴史的なものであり、これを使用する場合のほとんどでは、本当はテーブルのファイルノード番号(これはデータベースディレクトリ内で可視なファイル名)が関係しますので、実際誤解されやすいものです。 テーブルのOIDとテーブルファイルノードの違いを確実に理解してください。

<application>oid2name</application> connects to a target database and extracts OID, filenode, and/or table name information. You can also have it show database OIDs or tablespace OIDs. oid2nameは対象データベースに接続し、OID、ファイルノード、テーブル名情報を抽出します。 また、データベースOIDまたはテーブル空間OIDを示すようにさせることもできます。

オプション

<title>Options</title>

<application>oid2name</application> accepts the following command-line arguments: oid2nameは以下のコマンドライン引数を受け付けます。

-f filenode
--filenode=filenode

filenodeというファイルノードを持つテーブルの情報を表示します。

-i
--indexes

一覧にインデックスおよびシーケンスを含めます。

-o oid
--oid=oid

oidというOIDを持つテーブルの情報を表示します。

-q
--quiet

ヘッダを省略します。(スクリプト処理に適しています)

-s
--tablespaces

テーブル空間OIDを表示します。

-S
--system-objects

システムオブジェクト(information_schemapg_toastpg_catalogスキーマ内に存在するもの)を含めます。

-t tablename_pattern
--table=tablename_pattern

tablename_patternに一致するテーブル(複数可)の情報を表示します。

-V
--version

Print the <application>oid2name</application> version and exit. oid2nameのバージョンを表示し、終了します。

-x
--extended

表示対象の各オブジェクトに関してさらに情報を表示します。テーブル空間名、スキーマ名、OID。

-?
--help

Show help about <application>oid2name</application> command line arguments, and exit. oid2nameのコマンドライン引数の説明を表示し、終了します。

<application>oid2name</application> also accepts the following command-line arguments for connection parameters: またoid2nameは以下の接続用のパラメータに関するコマンドライン引数を受け付けます。

-d database
--dbname=database

接続データベース。

-h host
--host=host

データベースサーバのホスト。

-H host

データベースサーバのホスト。このパラメータの使用はPostgreSQL 12以降で廃止予定です。

-p port
--port=port

データベースサーバのポート。

-U username
--username=username

接続ユーザ名。

To display specific tables, select which tables to show by using <option>-o</option>, <option>-f</option> and/or <option>-t</option>. <option>-o</option> takes an OID, <option>-f</option> takes a filenode, and <option>-t</option> takes a table name (actually, it's a <literal>LIKE</literal> pattern, so you can use things like <literal>foo%</literal>). You can use as many of these options as you like, and the listing will include all objects matched by any of the options. But note that these options can only show objects in the database given by <option>-d</option>. 特定のテーブルを表示するために、-o-f-tを使用して表示するテーブルを選択してください。 -oはOIDを、-fはファイルノードを、-tはテーブル名(実際はLIKEパターンです。ですのでfoo%などが使用できます)を引数として取ります。 これらのオプションを必要なだけ使用することができます。 一覧には、オプションのいずれかで一致したオブジェクトがすべて含まれます。 しかしこれらのオプションでは、-dで指定したデータベース内に存在するオブジェクトしか表示しないことに注意してください。

If you don't give any of <option>-o</option>, <option>-f</option> or <option>-t</option>, but do give <option>-d</option>, it will list all tables in the database named by <option>-d</option>. In this mode, the <option>-S</option> and <option>-i</option> options control what gets listed. -o-f-tのいずれも指定せずに-dを指定した場合、-dで指定したデータベース上のすべてのテーブルを列挙します。 このモードでは、-Sおよび-iスイッチが何を列挙するかを制御します。

If you don't give <option>-d</option> either, it will show a listing of database OIDs. Alternatively you can give <option>-s</option> to get a tablespace listing. -dも指定しなかった場合、データベースOIDの一覧を示します。 他にも-sを指定してテーブル空間の一覧を得ることもできます。

環境

<title>Environment</title>
PGHOST
PGPORT
PGUSER

Default connection parameters. デフォルトの接続パラメータ。

This utility, like most other <productname>PostgreSQL</productname> utilities, also uses the environment variables supported by <application>libpq</application> (see <xref linkend="libpq-envars"/>). このユーティリティは、他の多くPostgreSQLユーティリティと同様に、libpqがサポートする環境変数(34.15参照)も使います。

The environment variable <envar>PG_COLOR</envar> specifies whether to use color in diagnostic messages. Possible values are <literal>always</literal>, <literal>auto</literal> and <literal>never</literal>. 環境変数PG_COLORは診断メッセージで色を使うかどうかを指定します。 可能な値はalwaysautoneverです。

注釈

<title>Notes</title>

<application>oid2name</application> requires a running database server with non-corrupt system catalogs. It is therefore of only limited use for recovering from catastrophic database corruption situations. oid2nameは破損のないシステムカタログで実行中のデータベースサーバが必要です。 したがって、破滅的にデータベースが破損したような状況からの復旧には限定的にしか役に立ちません。

<title>Examples</title>

$ # what's in this database server, anyway?

$ # とにかく、このデータベースサーバの中には何があるのだろう
$ oid2name
All databases:
    Oid  Database Name  Tablespace
----------------------------------
  17228       alvherre  pg_default
  17255     regression  pg_default
  17227      template0  pg_default
      1      template1  pg_default

$ oid2name -s
All tablespaces:
     Oid  Tablespace Name
-------------------------
    1663       pg_default
    1664        pg_global
  155151         fastdisk
  155152          bigdisk


$ # OK, let's look into database alvherre

$ # さて、データベースalvherreの中を見てみよう
$ cd $PGDATA/base/17228


$ # get top 10 db objects in the default tablespace, ordered by size

$ # デフォルトテーブル空間のデータベースオブジェクトを大きさの順に上位10個取得
$ ls -lS * | head -10
-rw-------  1 alvherre alvherre 136536064 sep 14 09:51 155173
-rw-------  1 alvherre alvherre  17965056 sep 14 09:51 1155291
-rw-------  1 alvherre alvherre   1204224 sep 14 09:51 16717
-rw-------  1 alvherre alvherre    581632 sep  6 17:51 1255
-rw-------  1 alvherre alvherre    237568 sep 14 09:50 16674
-rw-------  1 alvherre alvherre    212992 sep 14 09:51 1249
-rw-------  1 alvherre alvherre    204800 sep 14 09:51 16684
-rw-------  1 alvherre alvherre    196608 sep 14 09:50 16700
-rw-------  1 alvherre alvherre    163840 sep 14 09:50 16699
-rw-------  1 alvherre alvherre    122880 sep  6 17:51 16751


$ # I wonder what file 155173 is ...

$ # ファイル155173は何だろう
$ oid2name -d alvherre -f 155173
From database "alvherre":
  Filenode  Table Name
----------------------
    155173    accounts


$ # you can ask for more than one object

$ # 2つ以上のオブジェクトについて問い合わせることもできる
$ oid2name -d alvherre -f 155173 -f 1155291
From database "alvherre":
  Filenode     Table Name
-------------------------
    155173       accounts
   1155291  accounts_pkey


$ # you can mix the options, and get more details with -x

$ # オプションを複数指定することもできて、-xではより詳細を得ることができる
$ oid2name -d alvherre -t accounts -f 1155291 -x
From database "alvherre":
  Filenode     Table Name      Oid  Schema  Tablespace
------------------------------------------------------
    155173       accounts   155173  public  pg_default
   1155291  accounts_pkey  1155291  public  pg_default


$ # show disk space for every db object

$ # 各データベースオブジェクトのディスク容量を表示
$ du [0-9]* |
> while read SIZE FILENODE
> do
>   echo "$SIZE       `oid2name -q -d alvherre -i -f $FILENODE`"
> done
16            1155287  branches_pkey
16            1155289  tellers_pkey
17561            1155291  accounts_pkey
...


$ # same, but sort by size

$ # 同上、ただし大きさの順
$ du [0-9]* | sort -rn | while read SIZE FN
> do
>   echo "$SIZE   `oid2name -q -d alvherre -f $FN`"
> done
133466             155173    accounts
17561            1155291  accounts_pkey
1177              16717  pg_proc_proname_args_nsp_index
...


$ # If you want to see what's in tablespaces, use the pg_tblspc directory

$ # テーブル空間に何があるのか見たければ、pg_tblspcディレクトリを使う
$ cd $PGDATA/pg_tblspc
$ oid2name -s
All tablespaces:
     Oid  Tablespace Name
-------------------------
    1663       pg_default
    1664        pg_global
  155151         fastdisk
  155152          bigdisk


$ # what databases have objects in tablespace "fastdisk"?

$ # テーブル空間"fastdisk"にはどのデータベースのオブジェクトがあるのだろうか
$ ls -d 155151/*
155151/17228/  155151/PG_VERSION


$ # Oh, what was database 17228 again?

$ # おや、データベース17228がまた出てきた
$ oid2name
All databases:
    Oid  Database Name  Tablespace
----------------------------------
  17228       alvherre  pg_default
  17255     regression  pg_default
  17227      template0  pg_default
      1      template1  pg_default


$ # Let's see what objects does this database have in the tablespace.

$ # このデータベースがどのオブジェクトをこのテーブル空間に持っているのか見てみよう
$ cd 155151/17228
$ ls -l
total 0
-rw-------  1 postgres postgres 0 sep 13 23:20 155156


$ # OK, this is a pretty small table ... but which one is it?

$ # 分かった、これはかなり小さなテーブルだ、、、でも何のテーブルだろう
$ oid2name -d alvherre -f 155156
From database "alvherre":
  Filenode  Table Name
----------------------
    155156         foo

作者

<title>Author</title>

B. Palmer