pg_dump

Name

pg_dump  --  Extract a Postgres database into a script file Postgres データベースを スクリプトファイルに抽出する

Synopsis

pg_dump [ dbname ]
pg_dump [ -h host ] [ -p port ]
    [ -t table ] [ -f outputfile ]
    [ -a ] [ -c ] [ -d ] [ -D ] [ -n ] [ -N ]
    [ -o ] [ -s ] [ -u ] [ -v ] [ -x ]
    [ dbname ]
  

入力

pg_dump accepts the following command line arguments:

pg_dump は、以下のコマンドライン 引数を認めています:

dbname

Specifies the name of the database to be extracted. dbname defaults to the value of the USER environment variable.

抽出されるデータベース名。 デフォルトの dbname 名は、 環境変数 USER の値です。

-a

Dump out only the data, no schema (definitions).

データだけを抽出し、スキーマ (定義)は除きます。

-c

Clean(drop) schema prior to create.

作成前に、スキーマを排除します。

-d

Dump data as proper insert strings.

データを正しい挿入文として書き出します。

-D

Dump data as inserts with attribute names

データをアトリビュート (属性) 名付きで、挿入文として 書き出します。

-f filename

Specifies the output file. Defaults to stdout.

出力ファイル名を指定します。デフォルトでは、 stdout に出力します。

-n

Suppress double quotes around identifiers unless absolutely necessary. This may cause trouble loading this dumped data if there are reserved words used for identifiers. This was the default behavior in pre-v6.4 pg_dump.

まったく必要が無い場合は、識別子の前後に付けるダブルクォート (") の出力を行いません。 これにより、もし予約語が識別子として使われている場合、 書き出されたデータを読み込む場合に問題を引き起こすことが あります。 これは v6.4 以前の pg_dump のデフォルトの動作でした。

-N

Include double quotes around identifiers. This is the default.

識別子の前後にダブルクォート (") を付記します。 これが、デフォルトです。

-o

Dump object identifiers (OIDs) for every table.

すべてのテーブルのオブジェクトID (OIDs) を書き出します。

-s

Dump out only the schema (definitions), no data.

データを含まない、スキーマ (定義) だけを書き出します。

-t table

Dump data for table only.

table として 指定されたデータだけを書き出します。

-u

Use password authentication. Prompts for username and password.

パスワード認証を使います。ユーザ名とパスワードを 尋ねられます。

-v

Specifies verbose mode

冗長メッセージ (verbose) モードを指定します。

-x

Prevent dumping of ACLs (grant/revoke commands) and table ownership information.

アクセスコントロールリスト (ACL:grant/revoke コマンド) と テーブルの所有権に関する情報の書き出しを行いません。

pg_dump also accepts the following command line arguments for connection parameters:

pg_dump は、コマンドライン引数 として以下の接続パラメータも受け入れます:

-h host

Specifies the hostname of the machine on which the postmaster is running. Defaults to using a local Unix domain socket rather than an IP connection..

postmaster が動作しているホスト名 を指定します。デフォルトは、IP接続ではなくローカル Unix ドメインソケットを使用します。

-p port

Specifies the Internet TCP/IP port or local Unix domain socket file extension on which the postmaster is listening for connections. The port number defaults to 5432, or the value of the PGPORT environment variable (if set).

postmaster が接続を監視している インターネット TCP/IP ポート、あるいは ローカル Unix ドメインソケットファイル拡張子を指定します。 ポート番号は 5432 か、あるいは (もし設定されている場合は) PGPORT 環境変数の値をデフォルトとします。

-u

Use password authentication. Prompts for username and password.

パスワード認証を使用します。 usernamepassword を 尋ねられます。

出力

pg_dump will create a file or write to stdout.

pg_dump は、ファイルを作成するか、 あるいは stdout に書き出します。

Connection to database 'template1' failed. connectDB() failed: Is the postmaster running and accepting connections at 'UNIX Socket' on port 'port'?

pg_dump could not attach to the postmaster process on the specified host and port. If you see this message, ensure that the postmaster is running on the proper host and that you have specified the proper port. If your site uses an authentication system, ensure that you have obtained the required authentication credentials.

pg_dump は、指定されたホストと ポート上にある postmaster に 接続することができませんでした。このメッセージが表示された 場合、postmaster が正しいホスト上 で、指定した正しいポートで動作していることを確認してください。 もし認証システムを使用しているサイトの場合は、必要な認証資格 を持っているか確認してください

Connection to database 'dbname' failed. FATAL 1: SetUserId: user 'username' is not in 'pg_shadow'

You do not have a valid entry in the relation pg_shadow and and will not be allowed to access Postgres. Contact your Postgres administrator.

リレーション pg_shadow に有効な登録が されておらず、そして Postgres に アクセスすることを許されていません。 Postgres 管理者に連絡を取って ください。

dumpSequence(table): SELECT failed

You do not have permission to read the database. Contact your Postgres site administrator.

データベースを読む権限がありません。 Postgres サイト管理者に連絡を 取ってください。

Note: pg_dump internally executes SELECT statements. If you have problems running pg_dump, make sure you are able to select information from the database using, for example, psql.

pg_dump は、内部的には SELECT 文を実行します。もし、 pg_dump の使用時に問題がある場合 は、例えば psql を使用して、 使用しているデータベースから情報を選択することが出来ることを 確認してください。

説明

pg_dump is a utility for dumping out a Postgres database into a script file containing query commands. The script files are in text format and can be used to reconstruct the database, even on other machines and other architectures. pg_dump will produce the queries necessary to re-generate all user-defined types, functions, tables, indices, aggregates, and operators. In addition, all the data is copied out in text format so that it can be readily copied in again, as well as imported into tools for editing.

pg_dump は、 Postgres データベースを、 問い合わせコマンド (クエリ) を含めてスクリプトファイルの中へ 書き出すユーティリティです。 スクリプトファイルはテキスト形式で、データベースを再構築する ために使うことができます。そして、それは他のホストや、別の アーキテクチャ上にも再構築することもできます。 pg_dump は、ユーザが定義したすべて のデータ型、関数、テーブル、インデックス、集約関数と演算子 を再度生成するために必要な問い合わせを生成します。 加えて、すべてのデータはテキスト書式で書き出されるため、 編集の為のツールの中にインポートするのと同じぐらい、 簡単に再びコピーされることができるようになっています。

pg_dump is useful for dumping out the contents of a database to move from one Postgres installation to another. After running pg_dump, one should examine the output script file for any warnings, especially in light of the limitations listed below.

pg_dump は、 ある Postgres から、別にデータを移動する際にデータベースの内容を 書き出しせるので便利です。 pg_dump を使用した後、 出力されたスクリプトファイルに警告があるかどうか、特に、以下 の制限事項に書かれていることを考慮して、調査を行なって下さい。

注意

pg_dump has a few limitations. The limitations mostly stem from difficulty in extracting certain meta-information from the system catalogs.

pg_dump は、幾つかの制限事項を 持っています。 これらの制限事項は、システムカタログからある特定のメタ 情報を抽出することの困難さから大抵生じています。

使用法

To dump a database of the same name as the user:

ユーザ名と同じデータベースを書き出す場合、以下のようにします:

% pg_dump > db.out
   

To reload this database:

このデータベースを読み込むには以下のようにします:

% psql -e database < db.out