.\" This is -*-nroff-*- .\" XXX standard disclaimer belongs here.... .\" $Header: /usr/local/cvsroot/pgsql/src/man/copy.l,v 1.4 1998/01/11 22:17:11 momjian Exp $ .\" .\" Japanese Version Copyright (c) 1998 Michihide Hotta .\" all rights reserved. .\" Translated Wed Jun 3 18:46:34 JST 1998 .\" by Michihide Hotta .\" .TH COPY SQL 11/05/95 PostgreSQL PostgreSQL .\"0 .SH NAME .\"0 copy - copy data to or from a class from or to a Unix file. .SH 名前 copy - Unix ファイルからクラスへ、またはクラスから Unix ファイルへ データをコピーする。 .\"0 .SH SYNOPSIS .\"0 .nf .\"0 \fBcopy\fP [\fBbinary\fP] classname [\fBwith oids\fP] .\"0 \fBto\fP|\fBfrom '\fPfilename\fB'\fP|\fBstdin\fR|\fBstdout\fR .\"0 [\fBusing delimiters '\fPdelim\fB'\fP] .\"0 .fi .SH 書式 .nf \fBcopy\fP [\fBbinary\fP] クラス名 [\fBwith oids\fP] \fBto\fP|\fBfrom '\fPファイル名\fB'\fP|\fBstdin\fR|\fBstdout\fR [\fBusing delimiters '\fPデリミタ\fB'\fP] .fi .\"0 .SH DESCRIPTION .\"0 .BR Copy .\"0 moves data between Postgres classes and standard Unix files. .\"0 The keyword .\"0 .BR binary .\"0 changes the behavior of field formatting, as described below. .\"0 .IR Classname .\"0 is the name of an existing class. .\"0 The keyword .\"0 .BR "with oids" .\"0 copies the internal unique object id (OID) for each row. .\"0 .IR Classname .\"0 is the name of an existing class. .\"0 .IR Filename .\"0 is the absolute Unix pathname of the file. In place of a .\"0 filename, the keywords .\"0 .BR "stdin" " and " "stdout" .\"0 can be used so that input to .\"0 .BR copy .\"0 can be written by a Libpq application and output from the .\"0 .BR copy .\"0 command can be read by a Libpq application. .SH 説明 .BR Copy は Postgres のクラスと Unix ファイルの間でデータを移す。キーワード .BR binary は後述のように、フィールドの書式化に関する振る舞いを変更する。 .IR クラス名 は存在するクラスである。キーワード .BR "with oids" は、内部的にユニークな各行のオブジェクト ID (OID) もコピーする。 .IR ファイル名 はファイルの絶対 (Unix) パス名である。ファイル名の代わりに キーワード .BR "stdin" " と " "stdout" を使うことができるので、 .BR copy への入力は Libpq アプリケーションによって書き込むことができ、 .BR copy からの出力は Libpq アプリケーションによって読み込むことができる。 .PP .\"0 The .\"0 .BR binary .\"0 keyword will force all data to be stored/read as binary objects .\"0 rather than as ASCII text. It is somewhat faster than the normal .\"0 .BR copy .\"0 command, but is not generally portable, and the files generated .\"0 are somewhat larger, although this factor is highly dependent .\"0 on the data itself. .\"0 By default, a ASCII .\"0 .BR copy .\"0 uses a tab (\\t) character as a delimiter. The delimiter may .\"0 also be changed to any other single-character with the use of .\"0 .BR "using delimiters" . .\"0 Characters in data fields which happen to match the delimiter .\"0 character will be quoted. .BR binary キーワードを指定すると、すべてのデータを ASCII テキストではなく バイナリ・オブジェクトとして読み書きする。これは通常の .BR copy コマンドよりいくらか速いが、一般的にどのマシン間でも使えると いうわけではなく、また要因がデータそのものにあるとはいえ、 生成されたファイルはいくらか大きくなる。デフォルトでは、ASCII の .BR copy はデリミタとしてタブ (\\t) を使う。デリミタは .BR "using delimiters" を使って他の任意の 1 バイト文字に変更することができる。データ フィールドにあるデリミタ文字と同じ文字は、引用符で囲まれる。 .PP .\"0 You must have read access on any class whose values are read by the .\"0 .BR copy .\"0 command, and either write or append access to a class to which values .\"0 are being appended by the .\"0 .BR copy .\"0 command. あなたは、 .BR copy コマンドにより値が読まれるすべてのクラスに対しての 読み込み権が必要で、また .BR copy コマンドにより値が追加されるクラスへの書き込み権または追加権が 必要となる。 .\"0 .SH FORMAT OF OUTPUT FILES .\"0 .SS "ASCII COPY FORMAT" .\"0 When .\"0 .BR copy .\"0 is used without the .\"0 .BR binary .\"0 keyword, the file generated will have each instance on a line, .\"0 with each attribute separated by the delimiter character. .\"0 Embedded delimiter characters will be preceeded by a backslash .\"0 character (\\). The attribute values themselves are strings .\"0 generated by the output function associated with each attribute .\"0 type. The output function for a type should not try to generate .\"0 the backslash character; this will be handled by .\"0 .BR copy .\"0 itself. .SH 出力ファイルのフォーマット .SS "ASCII コピーフォーマット" .BR copy が .BR binary キーワードなしで使われると、生成されるファイルは 1 行に 1 インスタンスとなり、各属性はデリミタ文字で区切られる。 埋め込まれたデリミタ文字は、その前にバックスラッシュ文字 (\\) が付く。属性値自身は、各属性の型に関連付けられた出力関数により 生成される文字列となる。ある型のための出力関数は、バック スラッシュ文字を生成しようとしてはならない。この処理は .BR copy 自身が行う。 .PP .\"0 The actual format for each instance is .\"0 .nf .\"0 ... .\"0 .fi .\"0 The oid is placed on the beginning of the line if specified. 各インスタンスの実際のフォーマットは、以下のようになる。 .nf <属性1><タブ><属性2><タブ>...<タブ><属性n><ニューライン> .fi .PP .\"0 If .\"0 .BR copy .\"0 is sending its output to standard output instead of a file, .\"0 it will send a backslash(\\) and a period (.) followed .\"0 immediately by a newline, on a line by themselves, when .\"0 it is done. Similarly, if .\"0 .BR copy .\"0 is reading from standard input, it will expect a backslash .\"0 (\\) and a period (.) followed by a newline, as the first .\"0 three characters on a line, to denote end-of-file. However, .\"0 .BR copy .\"0 will terminate (followed by the backend itself) if a true .\"0 EOF is encountered. もし .BR copy がその出力をファイルの代わりに標準出力に送っている場合、処理が 完了すると、バックスラッシュ(\\)とピリオド(.)に続いてすぐに ニューラインが出力される。同様に、 .BR copy が標準入力からデータを読んでいる場合、ファイルの終了を検出する ために、バックスラッシュ(\\)、ピリオド(.)、ニューラインの 3 文字 からなる行を期待している。ただし、本当の EOF を検出した場合でも .BR copy (と、それに引き続いてバックエンドそのものも)は終了する。 .PP .\"0 The backslash character has special meaning. .\"0 .BR NULL .\"0 attributes are output as \\N. .\"0 A literal backslash character is output as two consecutive .\"0 backslashes. A literal tab character is represented as a .\"0 backslash and a tab. A literal newline character is .\"0 represented as a backslash and a newline. When loading ASCII .\"0 data not generated by PostgreSQL, you will need to .\"0 convert backslash characters (\\) to double-backslashes (\\\\) .\"0 so they are loaded properly. バックスラッシュ文字は特別な意味を持っている。 .BR NULL 属性は \\N として出力される。文字としてのバックスラッシュは、 2 つの連続したバックスラッシュで出力される。文字としてのタブ 文字は、バックスラッシュとタブで表現される。文字としてのニュー ラインは、バックスラッシュとニューラインで表現される。 PostgreSQL で作られたのではない ASCII データを読み込む場合、 適切に読み込みを行うために、バックスラッシュ文字 (\\) を二重 のバックスラッシュ文字 (\\\\) にコンバートしてやる必要がある。 .\"0 .SS "BINARY COPY FORMAT" .\"0 In the case of .\"0 .BR "copy binary" , .\"0 the first four bytes in the file will be the number of .\"0 instances in the file. If this number is .\"0 .IR zero, .\"0 the .\"0 .BR "copy binary" .\"0 command will read until end of file is encountered. .\"0 Otherwise, it will stop reading when this number of instances .\"0 has been read. Remaining data in the file will be ignored. .PP .\"0 The format for each instance in the file is as follows. Note .\"0 that this format must be followed .\"0 .BR EXACTLY . .\"0 Unsigned four-byte integer quantities are called uint32 in .\"0 the below description. ファイル中の各インスタンスのフォーマットを以下に示す。 このフォーマットは .BR 正確に 並んでいなければならないことに注意すること。以下の説明では、 符号無しの 4 バイト整数で表される量を uint32 と呼んでいる。 .\"0 .nf .\"0 The first value is: .\"0 uint32 number of tuples .\"0 then for each tuple: .\"0 uint32 total length of data segment .\"0 uint32 oid (if specified) .\"0 uint32 number of null attributes .\"0 [uint32 attribute number of first null attribute .\"0 ... .\"0 uint32 attribute number of nth null attribute], .\"0 .\"0 .fi .nf 最初の値: uint32 個のタプル そして、各タプルとして: uint32 データセグメントの全体長 uint32 oid (指定された場合) uint32 NULL 属性の数 [uint32 最初の NULL 属性の数 ... uint32 n 番目の NULL 属性の数], .fi .\"0 .bp <----なんだかよくわからないので消した .\"0 .SS "ALIGNMENT OF BINARY DATA" .\"0 On Sun-3s, 2-byte attributes are aligned on two-byte boundaries, .\"0 and all larger attributes are aligned on four-byte boundaries. .\"0 Character attributes are aligned on single-byte boundaries. .\"0 On other machines, all attributes larger than 1 byte are aligned .\"0 on four-byte boundaries. Note that variable length attributes .\"0 are preceded by the attribute's length; arrays are simply .\"0 contiguous streams of the array element type. .SS "バイナリデータのアライメント(バウンダリ調整)" Sun-3 では、2 バイトの属性は 2 バイト境界でバウンダリ調整が行われ、 それより大きいすべての属性は 4 バイト境界でバウンダリ調整される。 文字属性は 1 バイトバウンダリとなる。他のマシンでは、1 バイトより 大きい属性はすべて 4 バイトバウンダリとなる。可変長属性は、その 前に属性の長さが付加されることに注意すること。配列は、単に配列要素 の型の連続的なストリームである。 .\"0 .SH "SEE ALSO" .SH "関連項目" insert(l), create table(l), vacuum(l), libpq. .\"0 .SH BUGS .\"0 Files used as arguments to the .\"0 .BR copy .\"0 command must reside on or be accessible to the the database .\"0 server machine by being either on local disks or a networked .\"0 file system. .SH バグ .BR copy コマンドへの引数として使用されるファイルは、ローカルディスク上に 置くかまたはネットワークで共有されたファイルシステム上に置くなど の方法で、データベースマシン上に存在するか、またはアクセス可能で なければならない。 .PP .\"0 .BR Copy .\"0 stops operation at the first error. This should not lead to .\"0 problems in the event of a .\"0 .BR "copy from" , .\"0 but the target relation will, of course, be partially modified .\"0 in a .\"0 .BR "copy to" . .\"0 The .\"0 .IR vacuum (l) .\"0 query should be used to clean up after a failed .\"0 .BR "copy" . .BR Copy は最初のエラーで実行を停止する。これは、 .BR "copy from" 中に発生した問題の被害を拡大させないようにするためだが、もちろん .BR "copy to" においても対象となるリレーションが一部変更される。 .\"0 .BR "copy" に失敗した後は、エラーをクリアするために .IR vacuum (l) クエリーを使うべきであろう。 .PP .\"0 Because Postgres operates out of a different directory than .\"0 the user's working directory at the time Postgres is invoked, .\"0 the result of copying to a file \*(lqfoo\*(rq (without .\"0 additional path information) may yield unexpected results for .\"0 the naive user. In this case, \*(lqfoo\*(rq will wind up in .\"0 .SM $PGDATA\c .\"0 /foo. In general, the full pathname should be used when .\"0 specifying files to be copied. Postgres はその起動時に、ユーザのワークディレクトリ以外のところで 動作するため、ファイル \*(lqfoo\*(rq (パス情報がない場合)への コピーの結果がどこへいったかわからなくなるユーザもいる。こういった 場合は、 \*(lqfoo\*(rq は .SM $PGDATA\c /foo として出力されている。一般的に、コピーするファイルを指定する 場合はフルパスで指定する方がよいだろう。 .SH 翻訳者 堀田 倫英