-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp-pgrestore.html
More file actions
1107 lines (1098 loc) · 90.4 KB
/
app-pgrestore.html
File metadata and controls
1107 lines (1098 loc) · 90.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_restore</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgrecvlogical.html" title="pg_recvlogical" /><link rel="next" href="app-pgverifybackup.html" title="pg_verifybackup" /><meta name="viewport" content="width=device-width,initial-scale=1.0" /></head><body id="docContent" class="container-fluid col-10"><div class="other_version"><a href="https://www.postgresql.jp/document/">バージョンごとのドキュメント一覧</a></div><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="4" align="center"><a accesskey="h" href="index.html">PostgreSQL 18.3文書</a></th></tr><tr><td width="10%" align="left"></td><td width="10%" align="left"></td><td width="60%" align="center"><a href="reference-client.html" title="PostgreSQLクライアントアプリケーション">PostgreSQLクライアントアプリケーション</a></td><td width="20%" align="right"><div class="actions"><a class="issue" title="github" href="https://github.com/pgsql-jp/jpug-doc/issues/new?template=bug_report.yml&what-happened=version 18.3 : app-pgrestore.html">誤訳等の報告
</a></div></td></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgrecvlogical.html" title="pg_recvlogical">前へ</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQLクライアントアプリケーション">上へ</a></td><td width="60%" align="center"><span class="application">pg_restore</span></td><td width="20%" align="right"> <a accesskey="n" href="app-pgverifybackup.html" title="pg_verifybackup">次へ</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGRESTORE"><div class="titlepage"></div><a id="id-1.9.4.19.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_restore</span></span></h2><p>pg_restore —
<span class="original">
restore a <productname>PostgreSQL</productname> database from an
archive file created by <application>pg_dump</application>
</span>
<span class="application">pg_dump</span>によって作成されたアーカイブファイルから<span class="productname">PostgreSQL</span>データベースをリストアする
</p></div><div class="refsynopsisdiv"><h2>概要</h2><div class="cmdsynopsis"><p id="id-1.9.4.19.4.1"><code class="command">pg_restore</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...] [<em class="replaceable"><code>filename</code></em>]</p></div></div><div class="refsect1" id="APP-PGRESTORE-DESCRIPTION"><h2>説明</h2><span class="original">
<title>Description</title>
</span><p>
<span class="original">
<application>pg_restore</application> is a utility for restoring a
<productname>PostgreSQL</productname> database from an archive
created by <xref linkend="app-pgdump"/> in one of the non-plain-text
formats. It will issue the commands necessary to reconstruct the
database to the state it was in at the time it was saved. The
archive files also allow <application>pg_restore</application> to
be selective about what is restored, or even to reorder the items
prior to being restored. The archive files are designed to be
portable across architectures.
</span>
<span class="application">pg_restore</span>は、<a class="xref" href="app-pgdump.html" title="pg_dump"><span class="refentrytitle"><span class="application">pg_dump</span></span></a>によって作成された平文形式以外のアーカイブファイルを使って、<span class="productname">PostgreSQL</span>データベースをリストアするためのユーティリティです。
このコマンドは、データベースを再構成して保存された時点の状態にするために必要なコマンドを発行します。
また、<span class="application">pg_restore</span>は、アーカイブファイルから、リストアする内容を選択したり、リストアする前にアイテムの並べ替えを行うこともできます。
アーカイブファイルはアーキテクチャに依存しない移植性を持つように設計されています。
</p><p>
<span class="original">
<application>pg_restore</application> can operate in two modes.
If a database name is specified, <application>pg_restore</application>
connects to that database and restores archive contents directly into
the database. Otherwise, a script containing the SQL
commands necessary to rebuild the database is created and written
to a file or standard output. This script output is equivalent to
the plain text output format of <application>pg_dump</application>.
Some of the options controlling the output are therefore analogous to
<application>pg_dump</application> options.
</span>
<span class="application">pg_restore</span>の操作には2つのモードがあります。
データベース名が指定された場合、<span class="application">pg_restore</span>はそのデータベースに接続し、アーカイブを直接そのデータベースにリストアします。
データベース名が指定されなかった場合は、データベースを再構築するために必要となるSQLコマンドが含まれたスクリプトが作成されます(ファイルもしくは標準出力に書き出されます)。
このスクリプトの出力は<span class="application">pg_dump</span>の平文形式の出力と同じです。
従って、出力を制御するオプションの中には、<span class="application">pg_dump</span>のオプションに類似したものがあります。
</p><p>
<span class="original">
Obviously, <application>pg_restore</application> cannot restore information
that is not present in the archive file. For instance, if the
archive was made using the <quote>dump data as
<command>INSERT</command> commands</quote> option,
<application>pg_restore</application> will not be able to load the data
using <command>COPY</command> statements.
</span>
当然ながら、<span class="application">pg_restore</span>によって、アーカイブファイルに存在しない情報をリストアすることはできません。
例えば、アーカイブが<span class="quote">「<span class="quote"><code class="command">INSERT</code>コマンドの形式でデータダンプ</span>」</span>を行うオプションを使用して作成されたものであった場合、<span class="application">pg_restore</span>は<code class="command">COPY</code>文を使用してデータを読み込むことはできません。
</p><div class="warning"><h3 class="title">警告</h3><p>
<span class="original">
Restoring a dump causes the destination to execute arbitrary code of the
source superusers' choice. Partial dumps and partial restores do not limit
that. If the source superusers are not trusted, the dumped SQL statements
must be inspected before restoring. Non-plain-text dumps can be inspected
by using <application>pg_restore</application>'s <option>&#45;-file</option>
option. Note that the client running the dump and restore need not trust
the source or destination superusers.
</span>
ダンプをリストアすると、リストア先ではダンプ側のスーパーユーザが選択した任意のコードが実行されることになります。
部分的なダンプや部分的なリストアであってもそれは制限されません。
ダンプ側のスーパーユーザが信頼できない場合は、リストアする前にダンプされたSQL文を検査する必要があります。
非平文ダンプは、<span class="application">pg_restore</span>の<code class="option">--file</code>オプションを使って検査できます。
ダンプやリストアを実行するクライアントは、ダンプやリストア先のスーパーユーザを信頼する必要はありません。
</p></div></div><div class="refsect1" id="APP-PGRESTORE-OPTIONS"><h2>オプション</h2><span class="original">
<title>Options</title>
</span><p>
<span class="original">
<application>pg_restore</application> accepts the following command
line arguments.
</span>
<span class="application">pg_restore</span>は以下のコマンドライン引数を受け付けます。
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>filename</code></em></span></dt><dd><p>
<span class="original">
Specifies the location of the archive file (or directory, for a
directory-format archive) to be restored.
If not specified, the standard input is used.
</span>
リストアするアーカイブファイル(ディレクトリ書式アーカイブの場合はディレクトリ)の場所を指定します。
指定がない場合は、標準入力が使用されます。
</p></dd><dt><span class="term"><code class="option">-a</code><br /></span><span class="term"><code class="option">--data-only</code></span></dt><dd><p>
<span class="original">
Restore only the data, not the schema (data definitions) or statistics.
Table data, large objects, and sequence values are restored,
if present in the archive.
</span>
データのみをリストアし、スキーマ(データ定義)と統計情報はリストアしません。
アーカイブ内にある、テーブルデータ、ラージオブジェクト、およびシーケンス値がリストアされます。
</p><p>
<span class="original">
This option is similar to, but for historical reasons not identical
to, specifying <option>&#45;-section=data</option>.
</span>
このオプションは<code class="option">--section=data</code>を指定することと似ていますが、歴史的な理由により同一ではありません。
</p></dd><dt><span class="term"><code class="option">-c</code><br /></span><span class="term"><code class="option">--clean</code></span></dt><dd><p>
<span class="original">
Before restoring database objects, issue commands
to <command>DROP</command> all the objects that will be restored.
This option is useful for overwriting an existing database.
If any of the objects do not exist in the destination database,
ignorable error messages will be reported,
unless <option>&#45;-if-exists</option> is also specified.
</span>
データベースオブジェクトをリストアする前に、リストアされるすべてのオブジェクトを<code class="command">DROP</code>するコマンドを発行します。
このオプションは既存のデータベースを上書きする場合に便利です。
もし、対象のデータベースにオブジェクトが存在しない場合は、<code class="option">--if-exists</code>も指定しない限り、無視できるエラーメッセージが報告されます。
</p></dd><dt><span class="term"><code class="option">-C</code><br /></span><span class="term"><code class="option">--create</code></span></dt><dd><p>
<span class="original">
Create the database before restoring into it.
If <option>&#45;-clean</option> is also specified, drop and
recreate the target database before connecting to it.
</span>
リストア前にデータベースを作成します。
<code class="option">--clean</code>も同時に指定されている場合、接続する前に対象データベースを削除し再作成します。
</p><p>
<span class="original">
With <option>&#45;-create</option>, <application>pg_restore</application>
also restores the database's comment if any, and any configuration
variable settings that are specific to this database, that is,
any <command>ALTER DATABASE ... SET ...</command>
and <command>ALTER ROLE ... IN DATABASE ... SET ...</command>
commands that mention this database.
Access privileges for the database itself are also restored,
unless <option>&#45;-no-acl</option> is specified.
</span>
<code class="option">--create</code>では、<span class="application">pg_restore</span>は、もしあるならデータベースのコメントもリストアします。また、あらゆる設定変数の当データベースに対する設定、すなわち、このデータベースを対象にした<code class="command">ALTER DATABASE ... SET ...</code>と<code class="command">ALTER ROLE ... IN DATABASE ... SET ...</code>コマンドもリストアします。
<code class="option">--no-acl</code>が指定されていない限り、データベース自体に対するアクセス権限もリストアされます。
</p><p>
<span class="original">
When this option is used, the database named with <option>-d</option>
is used only to issue the initial <command>DROP DATABASE</command> and
<command>CREATE DATABASE</command> commands. All data is restored into the
database name that appears in the archive.
</span>
このオプションがある場合、<code class="option">-d</code>で指定したデータベースは最初の<code class="command">DROP DATABASE</code>と<code class="command">CREATE DATABASE</code>コマンドの発行時にのみ使用されます。
そして、すべてのデータはアーカイブ内に記述された名前のデータベースにリストアされます。
</p></dd><dt><span class="term"><code class="option">-d <em class="replaceable"><code>dbname</code></em></code><br /></span><span class="term"><code class="option">--dbname=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
<span class="original">
Connect to database <replaceable
class="parameter">dbname</replaceable> and restore directly
into the database. The <replaceable>dbname</replaceable> can
be a <link linkend="libpq-connstring">connection string</link>.
If so, connection string parameters will override any conflicting
command line options.
</span>
<em class="replaceable"><code>dbname</code></em>データベースに接続し、このデータベースに直接リストアします。
<em class="replaceable"><code>dbname</code></em>は<a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="32.1.1. 接続文字列">接続文字列</a>でも構いません。
その場合、接続文字列パラメータは衝突するコマンドラインオプションよりも優先します。
</p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--exit-on-error</code></span></dt><dd><p>
<span class="original">
Exit if an error is encountered while sending SQL commands to
the database. The default is to continue and to display a count of
errors at the end of the restoration.
</span>
データベースにSQLコマンドを送信中にエラーが発生した場合、処理を終了します。
デフォルトでは、処理を続行し、リストア処理の最後に発生したエラーの数を表示します。
</p></dd><dt><span class="term"><code class="option">-f <em class="replaceable"><code>filename</code></em></code><br /></span><span class="term"><code class="option">--file=<em class="replaceable"><code>filename</code></em></code></span></dt><dd><p>
<span class="original">
Specify output file for generated script, or for the listing
when used with <option>-l</option>. Use <literal>-</literal>
for <systemitem>stdout</systemitem>.
</span>
作成するスクリプト(<code class="option">-l</code>を使用した場合はアーカイブの一覧)の出力ファイルを指定します。
<span class="systemitem">stdout</span>(標準出力)に出力するには<code class="literal">-</code>を使ってください。
</p></dd><dt><span class="term"><code class="option">-F <em class="replaceable"><code>format</code></em></code><br /></span><span class="term"><code class="option">--format=<em class="replaceable"><code>format</code></em></code></span></dt><dd><p>
<span class="original">
Specify format of the archive. It is not necessary to specify
the format, since <application>pg_restore</application> will
determine the format automatically. If specified, it can be
one of the following:
</span>
アーカイブの形式を指定します。
<span class="application">pg_restore</span>は形式を自動認識するので、このオプションは必須ではありません。
指定する値は以下のいずれかになります。
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">c</code><br /></span><span class="term"><code class="literal">custom</code></span></dt><dd><p>
<span class="original">
The archive is in the custom format of
<application>pg_dump</application>.
</span>
アーカイブが<span class="application">pg_dump</span>のカスタム形式であることを表します。
</p></dd><dt><span class="term"><code class="literal">d</code><br /></span><span class="term"><code class="literal">directory</code></span></dt><dd><p>
<span class="original">
The archive is a directory archive.
</span>
アーカイブがディレクトリアーカイブであることを表します。
</p></dd><dt><span class="term"><code class="literal">t</code><br /></span><span class="term"><code class="literal">tar</code></span></dt><dd><p>
<span class="original">
The archive is a <command>tar</command> archive.
</span>
アーカイブが<code class="command">tar</code>アーカイブであることを表します。
</p></dd></dl></div></dd><dt><span class="term"><code class="option">-I <em class="replaceable"><code>index</code></em></code><br /></span><span class="term"><code class="option">--index=<em class="replaceable"><code>index</code></em></code></span></dt><dd><p>
<span class="original">
Restore definition of named index only. Multiple indexes
may be specified with multiple <option>-I</option> switches.
</span>
指定したインデックスの定義のみをリストアします。
複数の<code class="option">-I</code>スイッチをつけることで複数のインデックスを指定できます。
</p></dd><dt><span class="term"><code class="option">-j <em class="replaceable"><code>number-of-jobs</code></em></code><br /></span><span class="term"><code class="option">--jobs=<em class="replaceable"><code>number-of-jobs</code></em></code></span></dt><dd><p>
<span class="original">
Run the most time-consuming steps
of <application>pg_restore</application> &mdash; those that load data,
create indexes, or create constraints &mdash; concurrently, using up
to <replaceable class="parameter">number-of-jobs</replaceable>
concurrent sessions. This option can dramatically reduce the time
to restore a large database to a server running on a
multiprocessor machine. This option is ignored when emitting a script
rather than connecting directly to a database server.
</span>
<span class="application">pg_restore</span>のもっとも時間がかかる部分、つまり、データのロード、インデックスの作成、制約の作成部分を最大<em class="replaceable"><code>number-of-jobs</code></em>の並行セッションを使用して実行します。
このオプションは、複数プロセッサマシンで稼働するサーバに大規模なデータベースをリストアする時間を劇的に減らすことができます。
データベースサーバに直接接続するのではなくスクリプトを生成する場合には、このオプションは無視されます。
</p><p>
<span class="original">
Each job is one process or one thread, depending on the
operating system, and uses a separate connection to the
server.
</span>
各ジョブは1プロセスまたは1スレッド(オペレーティングシステムに依存)です。
各ジョブはサーバへの別々の接続を使用します。
</p><p>
<span class="original">
The optimal value for this option depends on the hardware
setup of the server, of the client, and of the network.
Factors include the number of CPU cores and the disk setup. A
good place to start is the number of CPU cores on the server,
but values larger than that can also lead to faster restore
times in many cases. Of course, values that are too high will
lead to decreased performance because of thrashing.
</span>
このオプションの最適値はサーバ、クライアント、ネットワークのハードウェア構成に依存します。
要素にはCPUコア数やディスク構成も含まれます。
試行する最初の値としてサーバのCPUコア数を勧めます。
しかし、多くの場合これより大きな値でもリストア時間を高速化することができます。
当然ながらあまりに大きな値を使用すると、スラッシングのために性能が劣化することになります。
</p><p>
<span class="original">
Only the custom and directory archive formats are supported
with this option.
The input must be a regular file or directory (not, for example, a
pipe or standard input). Also, multiple
jobs cannot be used together with the
option <option>&#45;-single-transaction</option>.
</span>
カスタムアーカイブ書式およびディレクトリアーカイブ書式のみがこのオプションをサポートします。
入力ファイルは通常のファイルまたはディレクトリでなければなりません(例えばパイプや標準入力はいけません)。
また、複数ジョブは<code class="option">--single-transaction</code>オプションといっしょに使用することはできません。
</p></dd><dt><span class="term"><code class="option">-l</code><br /></span><span class="term"><code class="option">--list</code></span></dt><dd><p>
<span class="original">
List the table of contents of the archive. The output of this operation
can be used as input to the <option>-L</option> option. Note that
if filtering switches such as <option>-n</option> or <option>-t</option> are
used with <option>-l</option>, they will restrict the items listed.
</span>
アーカイブの内容を一覧表として出力します。
このコマンドが出力する一覧は、<code class="option">-L</code>オプションに対する入力として使用することができます。
<code class="option">-n</code>や<code class="option">-t</code>などのフィルタオプションを<code class="option">-l</code>といっしょに使用すると、一覧出力する項目が制限されます。
</p></dd><dt><span class="term"><code class="option">-L <em class="replaceable"><code>list-file</code></em></code><br /></span><span class="term"><code class="option">--use-list=<em class="replaceable"><code>list-file</code></em></code></span></dt><dd><p>
<span class="original">
Restore only those archive elements that are listed in <replaceable
class="parameter">list-file</replaceable>, and restore them in the
order they appear in the file. Note that
if filtering switches such as <option>-n</option> or <option>-t</option> are
used with <option>-L</option>, they will further restrict the items restored.
</span>
<em class="replaceable"><code>list-file</code></em>内で指定したアーカイブ要素のみをリストアします。
また、それらはそのファイルの出現順にリストアされます。
<code class="option">-n</code>や<code class="option">-t</code>などのフィルタオプションを<code class="option">-L</code>といっしょに使用すると、リストアする項目がさらに制限されます。
</p><span class="original">
<para><replaceable class="parameter">list-file</replaceable> is normally created by
editing the output of a previous <option>-l</option> operation.
Lines can be moved or removed, and can also
be commented out by placing a semicolon (<literal>;</literal>) at the
start of the line. See below for examples.
</span><p><em class="replaceable"><code>list-file</code></em>は通常、事前に行った<code class="option">-l</code>操作の出力を編集して作成されます。
行の移動や削除、または、行の先頭にセミコロン(<code class="literal">;</code>)を付けてコメントアウトすることが可能です。
後述の例を参照してください。
</p></dd><dt><span class="term"><code class="option">-n <em class="replaceable"><code>schema</code></em></code><br /></span><span class="term"><code class="option">--schema=<em class="replaceable"><code>schema</code></em></code></span></dt><dd><p>
<span class="original">
Restore only objects that are in the named schema. Multiple schemas
may be specified with multiple <option>-n</option> switches. This can be
combined with the <option>-t</option> option to restore just a
specific table.
</span>
指定されたスキーマ内のオブジェクトのみをリストアします。
複数の<code class="option">-n</code>スイッチをつけることで複数のスキーマを指定できます。
これは特定のテーブルのみをリストアするために<code class="option">-t</code>オプションと組み合わせることができます。
</p></dd><dt><span class="term"><code class="option">-N <em class="replaceable"><code>schema</code></em></code><br /></span><span class="term"><code class="option">--exclude-schema=<em class="replaceable"><code>schema</code></em></code></span></dt><dd><p>
<span class="original">
Do not restore objects that are in the named schema. Multiple schemas
to be excluded may be specified with multiple <option>-N</option> switches.
</span>
指定したスキーマ内にあるオブジェクトをリストアしません。
<code class="option">-N</code>オプションを複数回指定することで、複数のスキーマを除外することができます。
</p><p>
<span class="original">
When both <option>-n</option> and <option>-N</option> are given for the same
schema name, the <option>-N</option> switch wins and the schema is excluded.
</span>
同じスキーマ名が<code class="option">-n</code>と<code class="option">-N</code>の両方で指定された場合は、<code class="option">-N</code>オプションが優先し、そのスキーマは除外されます。
</p></dd><dt><span class="term"><code class="option">-O</code><br /></span><span class="term"><code class="option">--no-owner</code></span></dt><dd><p>
<span class="original">
Do not output commands to set
ownership of objects to match the original database.
By default, <application>pg_restore</application> issues
<command>ALTER OWNER</command> or
<command>SET SESSION AUTHORIZATION</command>
statements to set ownership of created schema elements.
These statements will fail unless the initial connection to the
database is made by a superuser
(or the same user that owns all of the objects in the script).
With <option>-O</option>, any user name can be used for the
initial connection, and this user will own all the created objects.
</span>
オブジェクトの所有者を元のデータベースに合わせるためのコマンドを出力しません。
デフォルトでは、<span class="application">pg_restore</span>は、<code class="command">ALTER OWNER</code>または<code class="command">SET SESSION AUTHORIZATION</code>を発行して、作成したスキーマ要素の所有者を設定します。
データベースに最初に接続したのがスーパーユーザ(もしくは、そのスクリプト内の全てのオブジェクトを所有するユーザ)でない場合、これらの文は失敗します。
<code class="option">-O</code>を付与すると、初期接続に任意のユーザ名を使用できるようになります。ただし、この場合は、全てのオブジェクトの所有者がリストアしたユーザになります。
</p></dd><dt><span class="term"><code class="option">-P <em class="replaceable"><code>function-name(argtype [, ...])</code></em></code><br /></span><span class="term"><code class="option">--function=<em class="replaceable"><code>function-name(argtype [, ...])</code></em></code></span></dt><dd><p>
<span class="original">
Restore the named function only. Be careful to spell the function
name and arguments exactly as they appear in the dump file's table
of contents. Multiple functions may be specified with multiple
<option>-P</option> switches.
</span>
指定した関数のみをリストアします。
関数や引数の名前は、ダンプファイルの一覧で出力される通りのスペルで正確に入力するよう注意してください。
複数の<code class="option">-P</code>スイッチをつけることで複数の関数を指定できます。
</p></dd><dt><span class="term"><code class="option">-R</code><br /></span><span class="term"><code class="option">--no-reconnect</code></span></dt><dd><p>
<span class="original">
This option is obsolete but still accepted for backwards
compatibility.
</span>
このオプションは廃止されました。後方互換性を保持するために受け入れられています。
</p></dd><dt><span class="term"><code class="option">-s</code><br /></span><span class="term"><code class="option">--schema-only</code></span></dt><dd><p>
<span class="original">
Restore only the schema (data definitions), not data,
to the extent that schema entries are present in the archive.
</span>
アーカイブ内にあるスキーマ項目の範囲でスキーマ(データ定義)のみをリストアし、データ(テーブルの内容)をリストアしません。
</p><p>
<span class="original">
This option cannot be used with <option>&#45;-data-only</option>
or <option>&#45;-statistics-only</option>.
It is similar to, but for historical reasons not identical to,
specifying
<option>&#45;-section=pre-data &#45;-section=post-data &#45;-no-statistics</option>.
</span>
このオプションは、<code class="option">--data-only</code>や<code class="option">--statistics-only</code>と一緒に使用することはできません。
これは<code class="option">--section=pre-data --section=post-data --no-statistics</code>を指定することと似ていますが、歴史的な理由のため同一ではありません。
</p><p>
<span class="original">
(Do not confuse this with the <option>&#45;-schema</option> option, which
uses the word <quote>schema</quote> in a different meaning.)
</span>
(これと<code class="option">--schema</code>オプションと混同しないでください。<span class="quote">「<span class="quote">schema</span>」</span>という単語を異なる意味で使用しています。)
</p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--superuser=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
<span class="original">
Specify the superuser user name to use when disabling triggers.
This is relevant only if <option>&#45;-disable-triggers</option> is used.
</span>
トリガを無効にする場合に使用する、スーパーユーザのユーザ名を指定します。
これは<code class="option">--disable-triggers</code>を使う場合にのみ使用されます。
</p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>table</code></em></code><br /></span><span class="term"><code class="option">--table=<em class="replaceable"><code>table</code></em></code></span></dt><dd><p>
<span class="original">
Restore definition and/or data of only the named table.
For this purpose, <quote>table</quote> includes views, materialized views,
sequences, and foreign tables. Multiple tables
can be selected by writing multiple <option>-t</option> switches.
This option can be combined with the <option>-n</option> option to
specify table(s) in a particular schema.
</span>
指定されたテーブルのみについて、定義、データまたはその両方をリストアします。
この目的において、<span class="quote">「<span class="quote">テーブル</span>」</span>にはビュー、マテリアライズドビュー、シーケンス、外部テーブルが含まれます。
複数の<code class="option">-t</code>スイッチを指定することで複数のテーブルを指定することができます。
<code class="option">-n</code>オプションと組み合わせることでスキーマを指定することができます。
</p><div class="note"><h3 class="title">注記</h3><p>
<span class="original">
When <option>-t</option> is specified, <application>pg_restore</application>
makes no attempt to restore any other database objects that the
selected table(s) might depend upon. Therefore, there is no
guarantee that a specific-table restore into a clean database will
succeed.
</span>
<code class="option">-t</code>が指定された場合、<span class="application">pg_restore</span>は選択されたテーブルが依存するその他のデータベースオブジェクトについてリストアしようとはしません。
そのため、初期化されたデータベースに特定のテーブルをリストアすることが成功する保証はありません。
</p></div><div class="note"><h3 class="title">注記</h3><p>
<span class="original">
This flag does not behave identically to the <option>-t</option>
flag of <application>pg_dump</application>. There is not currently
any provision for wild-card matching in <application>pg_restore</application>,
nor can you include a schema name within its <option>-t</option>.
And, while <application>pg_dump</application>'s <option>-t</option>
flag will also dump subsidiary objects (such as indexes) of the
selected table(s),
<application>pg_restore</application>'s <option>-t</option>
flag does not include such subsidiary objects.
</span>
このフラグは<span class="application">pg_dump</span>の<code class="option">-t</code>フラグと同じ動作をするわけではありません。
現在のところ、<span class="application">pg_restore</span>でワイルドカードマッチを提供する予定はありませんし、<code class="option">-t</code>でスキーマ名を含めることもできません。
加えて、<span class="application">pg_dump</span>の<code class="option">-t</code>フラグは選択されたテーブルの(インデックスなどの)従属オブジェクトもダンプしますが、<span class="application">pg_restore</span>の<code class="option">-t</code>フラグではそのような従属オブジェクトを含めません。
</p></div><div class="note"><h3 class="title">注記</h3><p>
<span class="original">
In versions prior to <productname>PostgreSQL</productname> 9.6, this flag
matched only tables, not any other type of relation.
</span>
<span class="productname">PostgreSQL</span>の9.6より前のバージョンでは、このフラグはテーブルにのみマッチし、その他の種類のリレーションとはマッチしませんでした。
</p></div></dd><dt><span class="term"><code class="option">-T <em class="replaceable"><code>trigger</code></em></code><br /></span><span class="term"><code class="option">--trigger=<em class="replaceable"><code>trigger</code></em></code></span></dt><dd><p>
<span class="original">
Restore named trigger only. Multiple triggers may be specified with
multiple <option>-T</option> switches.
</span>
指定されたトリガだけをリストアします。
複数の<code class="option">-T</code>スイッチをつけることで、複数のトリガを指定できます。
</p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p>
<span class="original">
Specifies verbose mode. This will cause
<application>pg_restore</application> to output detailed object
comments and start/stop times to the output file, and progress
messages to standard error.
Repeating the option causes additional debug-level messages
to appear on standard error.
</span>
冗長モードを指定します。
これを指定すると、<span class="application">pg_restore</span>は詳細なオブジェクトコメント、開始時刻と終了時刻を出力ファイルに、進行メッセージを標準エラーに出力するようになります。
オプションを繰り返すと、追加のデバッグレベルメッセージが標準エラーに現れます。
</p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>
<span class="original">
Print the <application>pg_restore</application> version and exit.
</span>
<span class="application">pg_restore</span>のバージョンを表示し、終了します。
</p></dd><dt><span class="term"><code class="option">-x</code><br /></span><span class="term"><code class="option">--no-privileges</code><br /></span><span class="term"><code class="option">--no-acl</code></span></dt><dd><p>
<span class="original">
Prevent restoration of access privileges (grant/revoke commands).
</span>
アクセス権限(grant/revokeコマンド)のリストアを行いません。
</p></dd><dt><span class="term"><code class="option">-1</code><br /></span><span class="term"><code class="option">--single-transaction</code></span></dt><dd><p>
<span class="original">
Execute the restore as a single transaction (that is, wrap the
emitted commands in <command>BEGIN</command>/<command>COMMIT</command>). This
ensures that either all the commands complete successfully, or no
changes are applied. This option implies
<option>&#45;-exit-on-error</option>.
</span>
リストアを単一トランザクションとして実行します(つまり発行するコマンドを<code class="command">BEGIN</code>/<code class="command">COMMIT</code>で囲みます)。
これにより確実に、すべてのコマンドが完全に成功するか、まったく変更がなされないかのどちらかになります。
このオプションは<code class="option">--exit-on-error</code>を意味します。
</p></dd><dt><span class="term"><code class="option">--disable-triggers</code></span></dt><dd><p>
<span class="original">
This option is relevant only when performing a restore without schema.
It instructs <application>pg_restore</application> to execute commands
to temporarily disable triggers on the target tables while
the data is restored. Use this if you have referential
integrity checks or other triggers on the tables that you
do not want to invoke during data restore.
</span>
このオプションは、スキーマを含まないダンプからリストアする際にしか適用されません。
データのリストア中、<span class="application">pg_restore</span>に対し、対象テーブル上のトリガを一時的に無効にするコマンドを実行するよう指示します。
このオプションは、データのリストア中には呼び出したくない参照整合性検査やその他のトリガがある場合に使用します。
</p><p>
<span class="original">
Presently, the commands emitted for
<option>&#45;-disable-triggers</option> must be done as superuser. So you
should also specify a superuser name with <option>-S</option> or,
preferably, run <application>pg_restore</application> as a
<productname>PostgreSQL</productname> superuser.
</span>
現在のところ、<code class="option">--disable-triggers</code>が生成するコマンドを実行するのは、スーパーユーザでなければなりません。
そのため、<code class="option">-S</code>でスーパーユーザの名前を指定するか、あるいは、可能であれば、<span class="productname">PostgreSQL</span>のスーパーユーザ権限で<span class="application">pg_restore</span>を実行する必要があります。
</p></dd><dt><span class="term"><code class="option">--enable-row-security</code></span></dt><dd><p>
<span class="original">
This option is relevant only when restoring the contents of a table
which has row security. By default, <application>pg_restore</application> will set
<xref linkend="guc-row-security"/> to off, to ensure
that all data is restored in to the table. If the user does not have
sufficient privileges to bypass row security, then an error is thrown.
This parameter instructs <application>pg_restore</application> to set
<xref linkend="guc-row-security"/> to on instead, allowing the user to attempt to restore
the contents of the table with row security enabled. This might still
fail if the user does not have the right to insert the rows from the
dump into the table.
</span>
このオプションは、行セキュリティのあるテーブルの内容をリストアするときにのみ意味を持ちます。
デフォルトでは<span class="application">pg_restore</span>は<a class="xref" href="runtime-config-client.html#GUC-ROW-SECURITY">row_security</a>をoffに設定し、すべてのデータが確実にテーブルにリストアされるようにします。
ユーザが行セキュリティを回避できるだけの十分な権限がないときはエラーが発生します。
このパラメータは<span class="application">pg_restore</span>が<a class="xref" href="runtime-config-client.html#GUC-ROW-SECURITY">row_security</a>をonに設定するようにし、ユーザが行セキュリティが有効なテーブルの内容をリストアできるようにします。
それでも、ユーザがダンプからテーブルに行を挿入する権限を持っていなければ、これは失敗します。
</p><p>
<span class="original">
Note that this option currently also requires the dump be in <command>INSERT</command>
format, as <command>COPY FROM</command> does not support row security.
</span>
<code class="command">COPY FROM</code>は行セキュリティをサポートしないので、このオプションは今のところ、ダンプが<code class="command">INSERT</code>形式である必要があることに注意してください。
</p></dd><dt><span class="term"><code class="option">--filter=<em class="replaceable"><code>filename</code></em></code></span></dt><dd><p>
<span class="original">
Specify a filename from which to read patterns for objects excluded
or included from restore. The patterns are interpreted according to the
same rules as
<option>-n</option>/<option>&#45;-schema</option> for including objects in schemas,
<option>-N</option>/<option>&#45;-exclude-schema</option> for excluding objects in schemas,
<option>-P</option>/<option>&#45;-function</option> for restoring named functions,
<option>-I</option>/<option>&#45;-index</option> for restoring named indexes,
<option>-t</option>/<option>&#45;-table</option> for restoring named tables
or <option>-T</option>/<option>&#45;-trigger</option> for restoring triggers.
To read from <literal>STDIN</literal>, use <filename>-</filename> as the
filename. The <option>&#45;-filter</option> option can be specified in
conjunction with the above listed options for including or excluding
objects, and can also be specified more than once for multiple filter
files.
</span>
リストアに含めるまたは除外するオブジェクトのパターンを読み取るファイル名を指定します。
これらのパターンは対応するオプションと同じ規則に従って解釈されます。
スキーマ内のオブジェクトを含める場合は<code class="option">-n</code>/<code class="option">--schema</code>、
スキーマ内のオブジェクトを除外する場合は<code class="option">-N</code>/<code class="option">--exclude-schema</code>、
関数をリストアする場合は<code class="option">-P</code>/<code class="option">--function</code>、
インデックスをリストアする場合は<code class="option">-I</code>/<code class="option">--index</code>、
テーブルをリストアする場合は<code class="option">-t</code>/<code class="option">--table</code>、
トリガをリストアする場合は<code class="option">-T</code>/<code class="option">--trigger</code>。
<code class="literal">STDIN</code>から読み込むには、ファイル名として<code class="filename">-</code>を使用します。
<code class="option">--filter</code>オプションは、オブジェクトを含めるまたは除外するために、上記のオプションとともに指定でき、更に複数のファイルをフィルタするために複数回指定することもできます。
</p><p>
<span class="original">
The file lists one database pattern per row, with the following format:
</span>
ファイルには、オブジェクトパターンが1行に1つずつリストされ、次の形式になります。
</p><pre class="synopsis">
{ include | exclude } { function | index | schema | table | trigger } <em class="replaceable"><code>PATTERN</code></em>
</pre><p>
</p><p>
<span class="original">
The first keyword specifies whether the objects matched by the pattern
are to be included or excluded. The second keyword specifies the type
of object to be filtered using the pattern:
</span>
最初のキーワードは、パターンに一致するオブジェクトを含めるか除外するかを指定します。
2番目のキーワードは、パターンを使用してフィルタリングするオブジェクトのタイプを指定します。
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
<span class="original">
<literal>function</literal>: functions, works like the
<option>-P</option>/<option>&#45;-function</option> option. This keyword
can only be used with the <literal>include</literal> keyword.
</span>
<code class="literal">function</code>: 関数。
これは<code class="option">-P</code>/<code class="option">--function</code>オプションと同様に機能します。
このキーワードは<code class="literal">include</code>キーワードでのみ使用できます。
</p></li><li class="listitem"><p>
<span class="original">
<literal>index</literal>: indexes, works like the
<option>-I</option>/<option>&#45;-indexes</option> option. This keyword
can only be used with the <literal>include</literal> keyword.
</span>
<code class="literal">index</code>: インデックス。
これは<code class="option">-I</code>/<code class="option">--indexes</code>オプションと同様に機能します。
このキーワードは<code class="literal">include</code>キーワードでのみ使用できます。
</p></li><li class="listitem"><p>
<span class="original">
<literal>schema</literal>: schemas, works like the
<option>-n</option>/<option>&#45;-schema</option> and
<option>-N</option>/<option>&#45;-exclude-schema</option> options.
</span>
<code class="literal">schema</code>: スキーマ。
これは<code class="option">-n</code>/<code class="option">--schema</code>や<code class="option">-N</code>/<code class="option">--exclude-schema</code>オプションと同様に機能します。
</p></li><li class="listitem"><p>
<span class="original">
<literal>table</literal>: tables, works like the
<option>-t</option>/<option>&#45;-table</option> option. This keyword
can only be used with the <literal>include</literal> keyword.
</span>
<code class="literal">table</code>: テーブル。
<code class="option">-t</code>/<code class="option">--table</code>オプションと同様に機能します。
このキーワードは<code class="literal">include</code>キーワードと併用する場合のみ使用できます。
</p></li><li class="listitem"><p>
<span class="original">
<literal>trigger</literal>: triggers, works like the
<option>-T</option>/<option>&#45;-trigger</option> option. This keyword
can only be used with the <literal>include</literal> keyword.
</span>
<code class="literal">trigger</code>: トリガ。
これは<code class="option">-T</code>/<code class="option">--trigger</code>オプションと同様に機能します。
このキーワードは<code class="literal">include</code>キーワードでのみ使用できます。
</p></li></ul></div><p>
</p><p>
<span class="original">
Lines starting with <literal>#</literal> are considered comments and
ignored. Comments can be placed after an object pattern row as well.
Blank lines are also ignored. See <xref linkend="app-psql-patterns"/>
for how to perform quoting in patterns.
</span>
<code class="literal">#</code>で始まる行はコメントと見なされ、無視されます。
コメントはオブジェクトパターン行の後にも置くことができます。
空行も無視されます。
パターン内の引用符の実行方法については<a class="xref" href="app-psql.html#APP-PSQL-PATTERNS" title="パターン">パターン</a>を参照してください。
</p></dd><dt><span class="term"><code class="option">--if-exists</code></span></dt><dd><p>
<span class="original">
Use <literal>DROP ... IF EXISTS</literal> commands to drop objects
in <option>&#45;-clean</option> mode. This suppresses <quote>does not
exist</quote> errors that might otherwise be reported. This
option is not valid unless <option>&#45;-clean</option> is also
specified.
</span>
<code class="literal">DROP ... IF EXISTS</code>コマンドを使用して、<code class="option">--clean</code>モードでオブジェクトを削除します。
これは、そうでなければ報告される<span class="quote">「<span class="quote">does not exist</span>」</span>エラーを抑制します。
このオプションは、<code class="option">--clean</code>も指定されていない場合は無効です。
</p></dd><dt><span class="term"><code class="option">--no-comments</code></span></dt><dd><p>
<span class="original">
Do not output commands to restore comments, even if the archive
contains them.
</span>
たとえアーカイブにコメントが含まれていても、コメントをリストアするコマンドを出力しません。
</p></dd><dt><span class="term"><code class="option">--no-data</code></span></dt><dd><p>
<span class="original">
Do not output commands to restore data, even if the archive
contains them.
</span>
アーカイブにデータが含まれていたとしても、それをリストアするコマンドを出力しません。
</p></dd><dt><span class="term"><code class="option">--no-data-for-failed-tables</code></span></dt><dd><p>
<span class="original">
By default, table data is restored even if the creation command
for the table failed (e.g., because it already exists).
With this option, data for such a table is skipped.
This behavior is useful if the target database already
contains the desired table contents. For example,
auxiliary tables for <productname>PostgreSQL</productname> extensions
such as <productname>PostGIS</productname> might already be loaded in
the target database; specifying this option prevents duplicate
or obsolete data from being loaded into them.
</span>
デフォルトでは、関連するテーブルの作成に失敗した(たとえば、既に存在するなどの理由により)としてもテーブルデータオブジェクトはリストアされます。
このオプションにより、こうしたテーブルデータは単に無視されるようになります。
これは対象のデータベースに目的のテーブルの中身が含まれている時に便利です。
たとえば<span class="productname">PostGIS</span>などの<span class="productname">PostgreSQL</span>拡張用の補助テーブルが既に対象のデータベース内に存在する可能性があります。
このオプションを指定すれば、二重ロードや古いデータのロードを防ぐことができます。
</p><p>
<span class="original">
This option is effective only when restoring directly into a
database, not when producing SQL script output.
</span>
このオプションは直接データベースにリストアする時にのみ有効で、SQLスクリプト出力を生成する時は無効です。
</p></dd><dt><span class="term"><code class="option">--no-policies</code></span></dt><dd><p>
<span class="original">
Do not output commands to restore row security policies, even if
the archive contains them.
</span>
アーカイブに行セキュリティポリシーが含まれていたとしても、それをリストアするコマンドを出力しません。
</p></dd><dt><span class="term"><code class="option">--no-publications</code></span></dt><dd><p>
<span class="original">
Do not output commands to restore publications, even if the archive
contains them.
</span>
アーカイブにパブリケーションが含まれていたとしても、それをリストアするコマンドを出力しません。
</p></dd><dt><span class="term"><code class="option">--no-schema</code></span></dt><dd><p>
<span class="original">
Do not output commands to restore schema (data definitions), even if
the archive contains them.
</span>
アーカイブにスキーマ(データ定義)が含まれていたとしても、それをリストアするコマンドを出力しません。
</p></dd><dt><span class="term"><code class="option">--no-security-labels</code></span></dt><dd><p>
<span class="original">
Do not output commands to restore security labels,
even if the archive contains them.
</span>
アーカイブにセキュリティラベルが含まれている場合であっても、セキュリティラベルを戻すコマンドを出力しません。
</p></dd><dt><span class="term"><code class="option">--no-statistics</code></span></dt><dd><p>
<span class="original">
Do not output commands to restore statistics, even if the archive
contains them.
</span>
アーカイブに統計情報が含まれていたとしても、それをリストアするコマンドを出力しません。
</p></dd><dt><span class="term"><code class="option">--no-subscriptions</code></span></dt><dd><p>
<span class="original">
Do not output commands to restore subscriptions, even if the archive
contains them.
</span>
アーカイブにサブスクリプションが含まれていたとしても、それをリストアするコマンドを出力しません。
</p></dd><dt><span class="term"><code class="option">--no-table-access-method</code></span></dt><dd><p>
<span class="original">
Do not output commands to select table access methods.
With this option, all objects will be created with whichever
table access method is the default during restore.
</span>
テーブルアクセスメソッドを選択するコマンドを出力しません。
このオプションを付けると、すべてのオブジェクトはリストア時にデフォルトとなっているテーブルアクセスメソッドで作成されます。
</p></dd><dt><span class="term"><code class="option">--no-tablespaces</code></span></dt><dd><p>
<span class="original">
Do not output commands to select tablespaces.
With this option, all objects will be created in whichever
tablespace is the default during restore.
</span>
テーブル空間を選択するコマンドを出力しません。
このオプションを付けると、すべてのオブジェクトはリストア時にデフォルトとなっているテーブル空間内に作成されます。
</p></dd><dt><span class="term"><code class="option">--restrict-key=<em class="replaceable"><code>restrict_key</code></em></code></span></dt><dd><p>
<span class="original">
Use the provided string as the <application>psql</application>
<command>\restrict</command> key in the dump output. This can only be
specified for SQL script output, i.e., when the <option>&#45;-file</option>
option is used. If no restrict key is specified,
<application>pg_restore</application> will generate a random one as
needed. Keys may contain only alphanumeric characters.
</span>
指定した文字列をダンプ出力の<span class="application">psql</span>の<code class="command">\restrict</code>キーとして使用します。
これはSQLスクリプト出力、すなわち<code class="option">--file</code>オプションが使用される場合にのみ指定できます。
制限キーが指定されていない場合、<span class="application">pg_restore</span>は必要に応じてランダムなキーを生成します。
キーには英数字のみを使用できます。
</p><p>
<span class="original">
This option is primarily intended for testing purposes and other
scenarios that require repeatable output (e.g., comparing dump files).
It is not recommended for general use, as a malicious server with
advance knowledge of the key may be able to inject arbitrary code that
will be executed on the machine that runs
<application>psql</application> with the dump output.
</span>
このオプションは主にテスト目的や、出力の再現性が必要な場合(例えば、ダンプファイルの比較)を想定しています。
悪意のあるサーバがキーを事前に知っている場合、ダンプ出力を使って<span class="application">psql</span>を実行するマシンで任意のコードを実行できる可能性があるため、一般的な使用には推奨されません。
</p></dd><dt><span class="term"><code class="option">--section=<em class="replaceable"><code>sectionname</code></em></code></span></dt><dd><p>
<span class="original">
Only restore the named section. The section name can be
<option>pre-data</option>, <option>data</option>, or <option>post-data</option>.
This option can be specified more than once to select multiple
sections. The default is to restore all sections.
</span>
指定された部分のみをリストアします。
部分名は<code class="option">pre-data</code>、<code class="option">data</code>、<code class="option">post-data</code>のいずれかを取ることができます。
複数の部分を選択するために、このオプションを複数指定することができます。
デフォルトではすべての部分をリストアします。
</p><p>
<span class="original">
The data section contains actual table data as well as large-object
definitions.
Post-data items consist of definitions of indexes, triggers, rules
and constraints other than validated check constraints.
Pre-data items consist of all other data definition items.
</span>
data部分には、実際のテーブルデータやラージオブジェクト定義が含まれます。
post-data項目は、インデックス定義、トリガ定義、ルール定義、有効化された検査制約以外の制約定義から構成されます。
pre-data項目は、他のすべてのデータ定義項目から構成されます。
</p></dd><dt><span class="term"><code class="option">--statistics</code></span></dt><dd><p>
<span class="original">
Output commands to restore statistics, if the archive contains them.
This is the default.
</span>
アーカイブに統計情報が含まれている場合、それをリストアするコマンドを出力します。
これがデフォルトです。
</p></dd><dt><span class="term"><code class="option">--statistics-only</code></span></dt><dd><p>
<span class="original">
Restore only the statistics, not schema (data definitions) or data.
</span>
統計情報のみをリストアし、スキーマ(データ定義)とデータをリストアしません。
</p></dd><dt><span class="term"><code class="option">--strict-names</code></span></dt><dd><p>
<span class="original">
Require that each schema
(<option>-n</option>/<option>&#45;-schema</option>) and table
(<option>-t</option>/<option>&#45;-table</option>) qualifier match at
least one schema/table in the file to be restored.
</span>
各スキーマ指定(<code class="option">-n</code>/<code class="option">--schema</code>)およびテーブル指定(<code class="option">-t</code>/<code class="option">--table</code>)が、リストア対象のファイルに含まれるスキーマおよびテーブルと少なくとも1つマッチすることを必要とします。
</p></dd><dt><span class="term"><code class="option">--transaction-size=<em class="replaceable"><code>N</code></em></code></span></dt><dd><p>
<span class="original">
Execute the restore as a series of transactions, each processing
up to <replaceable class="parameter">N</replaceable> database
objects. This option implies <option>&#45;-exit-on-error</option>.
</span>
一連のトランザクションとしてリストアを実行します。
各トランザクションは最大<em class="replaceable"><code>N</code></em>個のデータベースオブジェクトを処理します。
このオプションは<code class="option">--exit-on-error</code>を意味します。
</p><p>
<span class="original">
<option>&#45;-transaction-size</option> offers an intermediate choice
between the default behavior (one transaction per SQL command)
and <option>-1</option>/<option>&#45;-single-transaction</option>
(one transaction for all restored objects).
While <option>&#45;-single-transaction</option> has the least
overhead, it may be impractical for large databases because the
transaction will take a lock on each restored object, possibly
exhausting the server's lock table space.
Using <option>&#45;-transaction-size</option> with a size of a few
thousand objects offers nearly the same performance benefits while
capping the amount of lock table space needed.
</span>
<code class="option">--transaction-size</code>は、デフォルトの動作(SQLコマンドごとに1トランザクション)と<code class="option">-1</code>/<code class="option">--single-transaction</code>(リストアされたすべてのオブジェクトに対して1トランザクション)の中間的な選択肢を提供します。
<code class="option">--single-transaction</code>は最もオーバーヘッドが少ないですが、大きなデータベースでは、リストアされたオブジェクトごとにトランザクションがロックを取得し、サーバのロックテーブル空間を使い果たす可能性があるため、実用的ではないかもしれません。
数千のオブジェクトを対象とする<code class="option">--transaction-size</code>を使用すると、必要なロックテーブル領域の量を制限しながら、ほぼ同じパフォーマンス上の利点が得られます。
</p></dd><dt><span class="term"><code class="option">--use-set-session-authorization</code></span></dt><dd><p>
<span class="original">
Output SQL-standard <command>SET SESSION AUTHORIZATION</command> commands
instead of <command>ALTER OWNER</command> commands to determine object
ownership. This makes the dump more standards-compatible, but
depending on the history of the objects in the dump, might not restore
properly.
</span>
<code class="command">ALTER OWNER</code>コマンドの代わりに、標準SQLの<code class="command">SET SESSION AUTHORIZATION</code>コマンドを出力して、オブジェクトの所有権を決定します。
これにより、ダンプの標準への互換性が高まりますが、ダンプ内のオブジェクトの履歴によっては正しくリストアされない可能性が生じます。
</p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
<span class="original">
Show help about <application>pg_restore</application> command line
arguments, and exit.
</span>
<span class="application">pg_restore</span>コマンドライン引数の使用方法を表示し、終了します。
</p></dd></dl></div><p>
</p><p>
<span class="original">
<application>pg_restore</application> also accepts
the following command line arguments for connection parameters:
</span>
<span class="application">pg_restore</span>はさらに以下のコマンドライン引数を接続パラメータとして受け付けます。
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the host name of the machine on which the server is
running. If the value begins with a slash, it is used as the
directory for the Unix domain socket. The default is taken
from the <envar>PGHOST</envar> environment variable, if set,
else a Unix domain socket connection is attempted.
</span>
サーバが稼働しているマシンのホスト名を指定します。
この値がスラッシュから始まる場合、Unixドメインソケット用のディレクトリとして使用されます。
デフォルトは、設定されていれば環境変数<code class="envar">PGHOST</code>から取得されます。
設定されていなければ、Unixドメインソケット接続とみなされます。
</p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>
<span class="original">
Specifies the TCP port or local Unix domain socket file
extension on which the server is listening for connections.
Defaults to the <envar>PGPORT</envar> environment variable, if
set, or a compiled-in default.
</span>
サーバが接続を監視するTCPポートもしくはローカルUnixドメインソケットファイルの拡張子を指定します。
デフォルトは、設定されている場合、環境変数<code class="envar">PGPORT</code>の値となります。設定されていなければ、コンパイル時のデフォルト値となります。
</p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>
<span class="original">
User name to connect as.
</span>
接続ユーザ名です。
</p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>
<span class="original">
Never issue a password prompt. If the server requires
password authentication and a password is not available by
other means such as a <filename>.pgpass</filename> file, the
connection attempt will fail. This option can be useful in
batch jobs and scripts where no user is present to enter a
password.
</span>
パスワードの入力を促しません。
サーバがパスワード認証を必要とし、かつ、<code class="filename">.pgpass</code>ファイルなどの他の方法が利用できない場合、接続試行は失敗します。
バッチジョブやスクリプトなどパスワードを入力するユーザが存在しない場合にこのオプションは有用かもしれません。
</p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>
<span class="original">
Force <application>pg_restore</application> to prompt for a
password before connecting to a database.
</span>
データベースに接続する前に、<span class="application">pg_restore</span>は強制的にパスワード入力を促します。
</p><p>
<span class="original">
This option is never essential, since
<application>pg_restore</application> will automatically prompt
for a password if the server demands password authentication.
However, <application>pg_restore</application> will waste a
connection attempt finding out that the server wants a password.
In some cases it is worth typing <option>-W</option> to avoid the extra
connection attempt.
</span>
サーバがパスワード認証を要求する場合<span class="application">pg_restore</span>は自動的にパスワード入力を促しますので、これが重要になることはありません。
しかし、<span class="application">pg_restore</span>は、サーバにパスワードが必要かどうかを判断するための接続試行を無駄に行います。
こうした余計な接続試行を防ぐために<code class="option">-W</code>の入力が有意となる場合もあります。
</p></dd><dt><span class="term"><code class="option">--role=<em class="replaceable"><code>rolename</code></em></code></span></dt><dd><p>
<span class="original">
Specifies a role name to be used to perform the restore.
This option causes <application>pg_restore</application> to issue a
<command>SET ROLE</command> <replaceable class="parameter">rolename</replaceable>
command after connecting to the database. It is useful when the
authenticated user (specified by <option>-U</option>) lacks privileges
needed by <application>pg_restore</application>, but can switch to a role with
the required rights. Some installations have a policy against
logging in directly as a superuser, and use of this option allows
restores to be performed without violating the policy.
</span>
リストアを実行する際に使用するロール名を指定します。
このオプションにより<span class="application">pg_restore</span>はデータベースに接続した後に<code class="command">SET ROLE</code> <em class="replaceable"><code>rolename</code></em>コマンドを発行するようになります。
認証に使用したユーザ(<code class="option">-U</code>で指定されたユーザ)が<span class="application">pg_restore</span>で必要とされる権限を持たないが、必要な権限を持つロールに切り替えることができる場合に有用です。
一部のインストレーションではスーパーユーザとして直接ログインさせないポリシーを取ることがありますが、このオプションを使用することでポリシーに反することなくリストアを行うことができます。
</p></dd></dl></div><p>
</p></div><div class="refsect1" id="id-1.9.4.19.7"><h2>環境</h2><span class="original">
<title>Environment</title>
</span><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGOPTIONS</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>
<span class="original">
Default connection parameters
</span>
デフォルトの接続パラメータです。
</p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
<span class="original">
Specifies whether to use color in diagnostic messages. Possible values
are <literal>always</literal>, <literal>auto</literal> and
<literal>never</literal>.
</span>
診断メッセージで色を使うかどうかを指定します。
指定可能な値は<code class="literal">always</code>、<code class="literal">auto</code>、<code class="literal">never</code>です。
</p></dd></dl></div><p>
<span class="original">
This utility, like most other <productname>PostgreSQL</productname> utilities,
also uses the environment variables supported by <application>libpq</application>
(see <xref linkend="libpq-envars"/>). However, it does not read
<envar>PGDATABASE</envar> when a database name is not supplied.
</span>
また、このユーティリティは、他のほとんどの<span class="productname">PostgreSQL</span>ユーティリティと同様、<span class="application">libpq</span>でサポートされる環境変数を使用します(<a class="xref" href="libpq-envars.html" title="32.15. 環境変数">32.15</a>を参照してください)。
しかしデータベース名が指定されていない場合は<code class="envar">PGDATABASE</code>は読み取られません。
</p></div><div class="refsect1" id="APP-PGRESTORE-DIAGNOSTICS"><h2>診断</h2><span class="original">
<title>Diagnostics</title>
</span><p>
<span class="original">
When a direct database connection is specified using the
<option>-d</option> option, <application>pg_restore</application>
internally executes <acronym>SQL</acronym> statements. If you have
problems running <application>pg_restore</application>, make sure
you are able to select information from the database using, for
example, <xref linkend="app-psql"/>. Also, any default connection
settings and environment variables used by the
<application>libpq</application> front-end library will apply.
</span>
<code class="option">-d</code>オプションによってデータベースに直接接続するよう指定されている場合、<span class="application">pg_restore</span>は内部で<acronym class="acronym">SQL</acronym>文を実行します。
<span class="application">pg_restore</span>の実行時に問題が発生する場合は、<a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a>などを使用して、そのデータベースから情報を選択できることを確認してください。
また、<span class="application">libpq</span>フロントエンドライブラリで使用されるデフォルト接続設定や環境変数もすべて適用されます。
</p></div><div class="refsect1" id="APP-PGRESTORE-NOTES"><h2>注釈</h2><span class="original">
<title>Notes</title>
</span><p>
<span class="original">
If your installation has any local additions to the
<literal>template1</literal> database, be careful to load the output of
<application>pg_restore</application> into a truly empty database;
otherwise you are likely to get errors due to duplicate definitions
of the added objects. To make an empty database without any local
additions, copy from <literal>template0</literal> not <literal>template1</literal>, for example:
</span>
<code class="literal">template1</code>データベースに対し独自の変更を行っている場合、<span class="application">pg_restore</span>の出力は、確実に空のデータベースにロードするよう注意してください。
そうしないと、おそらく追加されたオブジェクトの重複定義によってエラーが発生します。
独自の追加が反映されていない空のデータベースを作成するには、<code class="literal">template1</code>ではなく<code class="literal">template0</code>をコピーしてください。
以下に例を示します。
</p><pre class="programlisting">
CREATE DATABASE foo WITH TEMPLATE template0;
</pre><p>
</p><p>
<span class="original">
The limitations of <application>pg_restore</application> are detailed below.
</span>
<span class="application">pg_restore</span>の制限を以下に示します。
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
<span class="original">
When restoring data to a pre-existing table and the option
<option>&#45;-disable-triggers</option> is used,
<application>pg_restore</application> emits commands
to disable triggers on user tables before inserting the data, then emits commands to
re-enable them after the data has been inserted. If the restore is stopped in the
middle, the system catalogs might be left in the wrong state.
</span>
既存のテーブルにデータをリストアする際に<code class="option">--disable-triggers</code>オプションを使用すると、<span class="application">pg_restore</span>は、データを挿入する前に、ユーザテーブル上のトリガを無効にするコマンドを発行し、データの挿入が完了した後で、それらを再び有効にする問い合わせを発行します。
リストアが途中で停止した場合、システムカタログが不適切な状態のままになっている可能性があります。
</p></li><li class="listitem"><span class="original">
<para><application>pg_restore</application> cannot restore large objects
selectively; for instance, only those for a specific table. If
an archive contains large objects, then all large objects will be
restored, or none of them if they are excluded via <option>-L</option>,
<option>-t</option>, or other options.
</span><p><span class="application">pg_restore</span>は特定のテーブルのみのラージオブジェクトなどといった、ラージオブジェクトを選択してリストアすることはできません。
アーカイブにラージオブジェクトが含まれる場合、すべてのラージオブジェクトをリストアします。
もし<code class="option">-L</code>、<code class="option">-t</code>などのオプションで除外が指定されていた場合は、全くリストアしません。
</p></li></ul></div><p>
</p><p>
<span class="original">
See also the <xref linkend="app-pgdump"/> documentation for details on
limitations of <application>pg_dump</application>.
</span>
<span class="application">pg_dump</span>の制限についての詳細は、<a class="xref" href="app-pgdump.html" title="pg_dump"><span class="refentrytitle"><span class="application">pg_dump</span></span></a>の文書も参照してください。
</p><p>
<span class="original">
By default, <command>pg_restore</command> will restore optimizer statistics
if included in the dump file. If not all statistics were restored, it may
be useful to run <command>ANALYZE</command> on each restored table so the
optimizer has useful statistics; see <xref
linkend="vacuum-for-statistics"/> and <xref linkend="autovacuum"/> for more
information.
</span>
デフォルトでは、ダンプファイルにオプティマイザの統計情報が含まれる場合、<code class="command">pg_restore</code>はそれをリストアします。
もしすべての統計情報がリストアされなかった場合、オプティマイザが有用な統計情報を持つように、リストアしたテーブルそれぞれに対して<code class="command">ANALYZE</code>を実行することをお勧めします。
詳細については、<a class="xref" href="routine-vacuuming.html#VACUUM-FOR-STATISTICS" title="24.1.3. プランナ用の統計情報の更新">24.1.3</a>と<a class="xref" href="routine-vacuuming.html#AUTOVACUUM" title="24.1.6. 自動バキュームデーモン">24.1.6</a>を参照してください。
</p></div><div class="refsect1" id="APP-PGRESTORE-EXAMPLES"><h2>例</h2><span class="original">
<title>Examples</title>
</span><p>
<span class="original">
Assume we have dumped a database called <literal>mydb</literal> into a
custom-format dump file:
</span>
<code class="literal">mydb</code>という名前のデータベースをカスタム形式のダンプファイルにダンプしているものと仮定します。
</p><pre class="screen">
<code class="prompt">$</code> <strong class="userinput"><code>pg_dump -Fc mydb > db.dump</code></strong>