-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp-pgdump.html
More file actions
1828 lines (1812 loc) · 155 KB
/
app-pgdump.html
File metadata and controls
1828 lines (1812 loc) · 155 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_dump</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-pgconfig.html" title="pg_config" /><link rel="next" href="app-pg-dumpall.html" title="pg_dumpall" /><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-pgdump.html">誤訳等の報告
</a></div></td></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgconfig.html" title="pg_config">前へ</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_dump</span></td><td width="20%" align="right"> <a accesskey="n" href="app-pg-dumpall.html" title="pg_dumpall">次へ</a></td></tr></table><hr /></div><div class="refentry" id="APP-PGDUMP"><div class="titlepage"></div><a id="id-1.9.4.14.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_dump</span></span></h2><p>pg_dump —
<span class="original">
export a <productname>PostgreSQL</productname> database as an SQL script or to other formats
</span>
<span class="productname">PostgreSQL</span>データベースをSQLスクリプトまたは他の形式にエクスポートする
</p></div><div class="refsynopsisdiv"><h2>概要</h2><div class="cmdsynopsis"><p id="id-1.9.4.14.4.1"><code class="command">pg_dump</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...] [<em class="replaceable"><code>dbname</code></em>]</p></div></div><div class="refsect1" id="PG-DUMP-DESCRIPTION"><h2>説明</h2><span class="original">
<title>Description</title>
</span><p>
<span class="original">
<application>pg_dump</application> is a utility for exporting a
<productname>PostgreSQL</productname> database. It makes consistent
exports even if the database is being used concurrently.
<application>pg_dump</application> does not block other users
accessing the database (readers or writers).
Note, however, that except in simple cases,
<application>pg_dump</application> is generally not the right choice for
taking regular backups of production databases. See <xref
linkend="backup"/> for further discussion.
</span>
<span class="application">pg_dump</span>は<span class="productname">PostgreSQL</span>データベースをエクスポートするユーティリティです。
データベースを使用中であっても、一貫性のあるエクスポートを行うことができます。
<span class="application">pg_dump</span>は他のユーザによるデータベースへのアクセス(読み書き)をブロックしません。
ただし、単純な場合を除いて、<span class="application">pg_dump</span>は一般的に本番データベースの定期的なバックアップには適していないことに注意してください。
詳細な説明については<a class="xref" href="backup.html" title="第25章 バックアップとリストア">第25章</a>を参照してください。
</p><p>
<span class="original">
<application>pg_dump</application> only dumps a single database.
To export an entire cluster, or to export global objects that are
common to all databases in a cluster (such as roles and tablespaces),
use <xref linkend="app-pg-dumpall"/>.
</span>
<span class="application">pg_dump</span>は単一のデータベースしかダンプしません。
クラスタ全体、あるいは、クラスタ内の全データベースに共通のグローバルオブジェクト(ロールやテーブル空間など)をエクスポートするには<a class="xref" href="app-pg-dumpall.html" title="pg_dumpall"><span class="refentrytitle"><span class="application">pg_dumpall</span></span></a>を使用してください。
</p><p>
<span class="original">
Dumps can be output in script or archive file formats. Script
dumps are plain-text files containing the SQL commands required
to reconstruct the database to the state it was in at the time it was
saved. To restore from such a script, feed it to <xref
linkend="app-psql"/>. Script files
can be used to reconstruct the database even on other machines and
other architectures; with some modifications, even on other SQL
database products.
</span>
ダンプはスクリプト形式、または、アーカイブファイル形式で出力することができます。
スクリプトダンプは、保存した時点の状態のデータベースを再構成するために必要なSQLコマンドが書き込まれた平文ファイルです。
このスクリプトを使ってリストアを行うには、それを<a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a>に読み込ませます。
スクリプトファイルを使えば、ダンプを行ったのとは別のマシンや別のアーキテクチャ上でも、データベースを再構築することができます。
また、多少編集すれば他のSQLデータベース製品上でもデータベースの再構築が可能です。
</p><p>
<span class="original">
The alternative archive file formats must be used with
<xref linkend="app-pgrestore"/> to rebuild the database. They
allow <application>pg_restore</application> to be selective about
what is restored, or even to reorder the items prior to being
restored.
The archive file formats are designed to be portable across
architectures.
</span>
もう1つの形式であるアーカイブファイル形式を使ってデータベースを再構築するには、<a class="xref" href="app-pgrestore.html" title="pg_restore"><span class="refentrytitle"><span class="application">pg_restore</span></span></a>を使用しなければなりません。
このファイルを使用すると、<span class="application">pg_restore</span>がリストア対象を選択したり、リストアするアイテムを並べ替えたりできます。
アーカイブファイルもまた、アーキテクチャを越えて移植できるように設計されています。
</p><p>
<span class="original">
When used with one of the archive file formats and combined with
<application>pg_restore</application>,
<application>pg_dump</application> provides a flexible archival and
transfer mechanism. <application>pg_dump</application> can be used to
export an entire database, then <application>pg_restore</application>
can be used to examine the archive and/or select which parts of the
database are to be restored. The most flexible output file formats are
the <quote>custom</quote> format (<option>-Fc</option>) and the
<quote>directory</quote> format (<option>-Fd</option>). They allow
for selection and reordering of all archived items, support parallel
restoration, and are compressed by default. The <quote>directory</quote>
format is the only format that supports parallel dumps.
</span>
いずれかのアーカイブファイル形式を<span class="application">pg_restore</span>と組み合わせて使用する場合は、<span class="application">pg_dump</span>の柔軟なアーカイブ/転送機構が利用できます。
具体的には、<span class="application">pg_dump</span>を使用してデータベース全体をエクスポートし、<span class="application">pg_restore</span>を使用して、アーカイブの内容を検査したり、データベースの一部を選択してリストアしたりすることができます。
最も柔軟な出力ファイル形式は<span class="quote">「<span class="quote">カスタム</span>」</span>形式(<code class="option">-Fc</code>)と<span class="quote">「<span class="quote">ディレクトリ</span>」</span>形式(<code class="option">-Fd</code>)です。
これらはすべての保存された項目の選択や並べ替えを行うことができ、並行リストアをサポートし、デフォルトで圧縮されます。
<span class="quote">「<span class="quote">ディレクトリ</span>」</span>形式は、並行ダンプをサポートする唯一の形式です。
</p><p>
<span class="original">
While running <application>pg_dump</application>, one should examine the
output for any warnings (printed on standard error), especially in
light of the limitations listed below.
</span>
<span class="application">pg_dump</span>の実行中は、標準エラーに出力される警告(特に後述の制限に関する警告)が出力されていないか確認してください。
</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="PG-DUMP-OPTIONS"><h2>オプション</h2><span class="original">
<title>Options</title>
</span><p>
<span class="original">
The following command-line options control the content and
format of the output.
</span>
以下のコマンドラインオプションは出力内容とその形式を制御します。
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>dbname</code></em></span></dt><dd><p>
<span class="original">
Specifies the name of the database to be dumped. If this is
not specified, the environment variable
<envar>PGDATABASE</envar> is used. If that is not set, the
user name specified for the connection is used.
</span>
ダンプするデータベースの名前を指定します。
指定されていない場合は環境変数<code class="envar">PGDATABASE</code>が使われます。
この変数も設定されていない場合は、接続のために指定されたユーザ名が使用されます。
</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">
Dump only the data, not the schema (data definitions) or statistics.
Table data, large objects, and sequence values are dumped.
</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">-b</code><br /></span><span class="term"><code class="option">--large-objects</code><br /></span><span class="term"><code class="option">--blobs</code> (deprecated)</span></dt><dd><p>
<span class="original">
Include large objects in the dump. This is the default behavior
except when <option>&#45;-schema</option>, <option>&#45;-table</option>,
<option>&#45;-schema-only</option>, <option>&#45;-statistics-only</option>, or
<option>&#45;-no-data</option> is specified. The <option>-b</option>
switch is therefore only useful to add large objects to dumps where a
specific schema or table has been requested. Note that large objects
are considered data and therefore will be included when
<option>&#45;-data-only</option> is used, but not when
<option>&#45;-schema-only</option> or <option>&#45;-statistics-only</option>
is.
</span>
ラージオブジェクトをダンプに含めます。
<code class="option">--schema</code>、<code class="option">--table</code>、<code class="option">--schema-only</code>、<code class="option">--statistics-only</code>、または<code class="option">--no-data</code>が指定された場合を除き、これがデフォルトの動作です。
したがって、<code class="option">-b</code>オプションは特定のスキーマやテーブルのダンプにラージオブジェクトを追加する場合にのみ有用です。
ラージオブジェクトはデータとみなされるため、<code class="option">--data-only</code>が使われるときは含まれますが、<code class="option">--schema-only</code>や<code class="option">--statistics-only</code>が使われるときには含まれないことに注意してください。
</p></dd><dt><span class="term"><code class="option">-B</code><br /></span><span class="term"><code class="option">--no-large-objects</code><br /></span><span class="term"><code class="option">--no-blobs</code> (deprecated)</span></dt><dd><p>
<span class="original">
Exclude large objects in the dump.
</span>
ラージオブジェクトをダンプに含めません。
</p><p>
<span class="original">
When both <option>-b</option> and <option>-B</option> are given, the behavior
is to output large objects, when data is being dumped, see the
<option>-b</option> documentation.
</span>
<code class="option">-b</code>と<code class="option">-B</code>の両方が指定された場合は、データのダンプ時にラージオブジェクトを出力します。
<code class="option">-b</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">
Output commands to <command>DROP</command> all the dumped
database objects prior to outputting the commands for creating them.
This option is useful when the restore is to overwrite an existing
database. If any of the objects do not exist in the destination
database, ignorable error messages will be reported during
restore, unless <option>&#45;-if-exists</option> is also specified.
</span>
ダンプされたデータベースオブジェクトを作成するコマンドを出力する前に、それらをすべて<code class="command">DROP</code>するコマンドを出力します。
このオプションは、リストアが既存のデータベースを上書きする場合に便利です。
もし、対象のデータベースにオブジェクトが存在しない場合は、<code class="option">--if-exists</code>も指定しない限り、リストア中に無視できるエラーメッセージが報告されます。
</p><p>
<span class="original">
This option is ignored when emitting an archive (non-text) output
file. For the archive formats, you can specify the option when you
call <command>pg_restore</command>.
</span>
このオプションはアーカイブ(テキストでない)出力ファイルを出力する場合には無視されます。
アーカイブ形式では、<code class="command">pg_restore</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">
Begin the output with a command to create the
database itself and reconnect to the created database. (With a
script of this form, it doesn't matter which database in the
destination installation you connect to before running the script.)
If <option>&#45;-clean</option> is also specified, the script drops and
recreates the target database before reconnecting to it.
</span>
初めにデータベース自体を作成するコマンドを出力し、その後、作成したデータベースに接続するコマンドを出力します。
(このようなスクリプトを使用すると、スクリプトを実行する前に対象のインストレーションの中のどのデータベースに接続すればよいかという問題を考える必要がなくなります。)
<code class="option">--clean</code>も同時に指定されている場合、このスクリプトは接続する前に対象データベースを削除し再作成します。
</p><p>
<span class="original">
With <option>&#45;-create</option>, the output also includes 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 dumped,
unless <option>&#45;-no-acl</option> is specified.
</span>
<code class="option">--create</code>では出力に、もしあるならデータベースのコメントも含まれます。また、あらゆる設定変数の設定、すなわち、このデータベースを対象としている<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">
This option is ignored when emitting an archive (non-text) output
file. For the archive formats, you can specify the option when you
call <command>pg_restore</command>.
</span>
このオプションはアーカイブ(テキストでない)出力ファイルを出力する場合には無視されます。
アーカイブ形式では、<code class="command">pg_restore</code>を呼び出す時にこのオプションを指定できます。
</p></dd><dt><span class="term"><code class="option">-e <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--extension=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
<span class="original">
Dump only extensions matching <replaceable
class="parameter">pattern</replaceable>. When this option is not
specified, all non-system extensions in the target database will be
dumped. Multiple extensions can be selected by writing multiple
<option>-e</option> switches. The <replaceable
class="parameter">pattern</replaceable> parameter is interpreted as a
pattern according to the same rules used by
<application>psql</application>'s <literal>\d</literal> commands (see
<xref linkend="app-psql-patterns"/>), so multiple extensions can also
be selected by writing wildcard characters in the pattern. When using
wildcards, be careful to quote the pattern if needed to prevent the
shell from expanding the wildcards.
</span>
<em class="replaceable"><code>pattern</code></em>にマッチする拡張のみをダンプします。
このオプションが指定されなければ、対象データベース内にあるシステム以外の拡張すべてがダンプされます。
複数の<code class="option">-e</code>オプションを記述することで、複数の拡張を選択できます。
<em class="replaceable"><code>pattern</code></em>パラメータは<span class="application">psql</span>の<code class="literal">\d</code>コマンドと同じ規則に従うパターン(<a class="xref" href="app-psql.html#APP-PSQL-PATTERNS" title="パターン">パターン</a>参照)として解釈されます。ですので、ワイルドカード文字をパターン内に記述することで、複数の拡張を選択することもできます。
ワイルドカードを使用する時は、シェルがそのワイルドカードを展開しないように、必要であればパターンを引用符で括ってください。
</p><p>
<span class="original">
Any configuration relation registered by
<function>pg_extension_config_dump</function> is included in the
dump if its extension is specified by <option>&#45;-extension</option>.
</span>
<code class="function">pg_extension_config_dump</code>により登録された設定リレーションは、その拡張が<code class="option">--extension</code>で指定されていればダンプに含まれます。
</p><div class="note"><h3 class="title">注記</h3><p>
<span class="original">
When <option>-e</option> is specified,
<application>pg_dump</application> makes no attempt to dump any other
database objects that the selected extension(s) might depend upon.
Therefore, there is no guarantee that the results of a
specific-extension dump can be successfully restored by themselves
into a clean database.
</span>
<code class="option">-e</code>が指定されると、<span class="application">pg_dump</span>は選択した拡張が依存する可能性のある、その他のデータベースオブジェクトのダンプを行ないません。
したがって、拡張指定のダンプ結果を初期状態のデータベースに正常にリストアできるという保証はありません。
</p></div></dd><dt><span class="term"><code class="option">-E <em class="replaceable"><code>encoding</code></em></code><br /></span><span class="term"><code class="option">--encoding=<em class="replaceable"><code>encoding</code></em></code></span></dt><dd><p>
<span class="original">
Create the dump in the specified character set encoding. By default,
the dump is created in the database encoding. (Another way to get the
same result is to set the <envar>PGCLIENTENCODING</envar> environment
variable to the desired dump encoding.) The supported encodings are
described in <xref linkend="multibyte-charset-supported"/>.
</span>
指定した文字集合符号化方式でダンプを作成します。
デフォルトではダンプはデータベースの符号化方式で作成されます。
(環境変数<code class="envar">PGCLIENTENCODING</code>を好みのダンプ時の符号化方式に設定することで、同じ結果を得ることができます。)
サポートする符号化方式は<a class="xref" href="multibyte.html#MULTIBYTE-CHARSET-SUPPORTED" title="23.3.1. サポートされる文字集合">23.3.1</a>に記載されています。
</p></dd><dt><span class="term"><code class="option">-f <em class="replaceable"><code>file</code></em></code><br /></span><span class="term"><code class="option">--file=<em class="replaceable"><code>file</code></em></code></span></dt><dd><p>
<span class="original">
Send output to the specified file. This parameter can be omitted for
file based output formats, in which case the standard output is used.
It must be given for the directory output format however, where it
specifies the target directory instead of a file. In this case the
directory is created by <command>pg_dump</command> and must not exist
before.
</span>
出力を指定のファイルに送ります。
ファイルを基にする出力形式ではこのパラメータは省くことができます。
省略時は標準出力が使用されます。
しかしディレクトリ出力形式の場合は、省略することはできず、ファイルではなく対象ディレクトリを指定します。
この場合、ディレクトリは<code class="command">pg_dump</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">
Selects the format of the output.
<replaceable>format</replaceable> can be one of the following:
</span>
出力形式を選択します。
<em class="replaceable"><code>format</code></em>には以下のいずれかを取ることができます。
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">p</code><br /></span><span class="term"><code class="literal">plain</code></span></dt><dd><p>
<span class="original">
Output a plain-text <acronym>SQL</acronym> script file (the default).
</span>
平文の<acronym class="acronym">SQL</acronym>スクリプトファイルを出力します(デフォルト)。
</p></dd><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">
Output a custom-format archive suitable for input into
<application>pg_restore</application>.
Together with the directory output format, this is the most flexible
output format in that it allows manual selection and reordering of
archived items during restore. This format is also compressed by
default.
</span>
<span class="application">pg_restore</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">
Output a directory-format archive suitable for input into
<application>pg_restore</application>. This will create a directory
with one file for each table and large object being dumped, plus a
so-called Table of Contents file describing the dumped objects in a
machine-readable format that <application>pg_restore</application>
can read. A directory format archive can be manipulated with
standard Unix tools; for example, files in an uncompressed archive
can be compressed with the <application>gzip</application>,
<application>lz4</application>, or
<application>zstd</application> tools.
This format is compressed by default using <literal>gzip</literal>
and also supports parallel dumps.
</span>
<span class="application">pg_restore</span>への入力に適したディレクトリ形式のアーカイブを出力します。
これは、ダンプされる各テーブルおよびラージオブジェクトごとに1つのファイル、さらに、<span class="application">pg_restore</span>から読み取り可能な、機械的に読み取り易い書式でダンプしたオブジェクトを記述する目次ファイルと呼ばれるファイルを持つディレクトリを作成します。
ディレクトリ形式アーカイブは標準Unixツールで操作することができます。
例えば、未圧縮アーカイブ内のファイルをツール<span class="application">gzip</span>、<span class="application">lz4</span>、<span class="application">zstd</span>を使用して圧縮することができます。
この形式はデフォルトでは<code class="literal">gzip</code>を使って圧縮されます。
また並行ダンプをサポートします。
</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">
Output a <command>tar</command>-format archive suitable for input
into <application>pg_restore</application>. The tar format is
compatible with the directory format: extracting a tar-format
archive produces a valid directory-format archive.
However, the tar format does not support compression. Also, when
using tar format the relative order of table data items cannot be
changed during restore.
</span>
<span class="application">pg_restore</span>への入力に適した<code class="command">tar</code>形式のアーカイブを出力します。
このtar形式はディレクトリ形式と互換性があります。
tar形式アーカイブを展開すると、有効なディレクトリ形式のアーカイブを生成します。
しかしtar形式は圧縮をサポートしません。
またtar形式を使う場合、リストア時にテーブルデータ項目の相対的な順序を変更することはできません。
</p></dd></dl></div></dd><dt><span class="term"><code class="option">-j <em class="replaceable"><code>njobs</code></em></code><br /></span><span class="term"><code class="option">--jobs=<em class="replaceable"><code>njobs</code></em></code></span></dt><dd><p>
<span class="original">
Run the dump in parallel by dumping <replaceable class="parameter">njobs</replaceable>
tables simultaneously. This option may reduce the time needed to perform the dump but it also
increases the load on the database server. You can only use this option with the
directory output format because this is the only output format where multiple processes
can write their data at the same time.
</span>
<em class="replaceable"><code>njobs</code></em>個のテーブルを同時にダンプすることによって、並行してダンプを実行します。
このオプションはダンプを実行するのに必要な時間を減らすかもしれませんが、データベースサーバの負荷を増やします。
このオプションはディレクトリ出力形式でのみ使用することができます。
複数のプロセスが同時にそのデータを書き出すことができるのはディレクトリ形式だけだからです。
</p><span class="original">
<para><application>pg_dump</application> will open <replaceable class="parameter">njobs</replaceable>
+ 1 connections to the database, so make sure your <xref linkend="guc-max-connections"/>
setting is high enough to accommodate all connections.
</span><p>
<span class="application">pg_dump</span>は<em class="replaceable"><code>njobs</code></em>+1個のデータベース接続を開きます。
このため、すべての接続を収容できる程度に<a class="xref" href="runtime-config-connection.html#GUC-MAX-CONNECTIONS">max_connections</a>が高いことを確認してください。
</p><p>
<span class="original">
Requesting exclusive locks on database objects while running a parallel dump could
cause the dump to fail. The reason is that the <application>pg_dump</application> leader process
requests shared locks (<link linkend="locking-tables">ACCESS SHARE</link>) on the
objects that the worker processes are going to dump later in order to
make sure that nobody deletes them and makes them go away while the dump is running.
If another client then requests an exclusive lock on a table, that lock will not be
granted but will be queued waiting for the shared lock of the leader process to be
released. Consequently any other access to the table will not be granted either and
will queue after the exclusive lock request. This includes the worker process trying
to dump the table. Without any precautions this would be a classic deadlock situation.
To detect this conflict, the <application>pg_dump</application> worker process requests another
shared lock using the <literal>NOWAIT</literal> option. If the worker process is not granted
this shared lock, somebody else must have requested an exclusive lock in the meantime
and there is no way to continue with the dump, so <application>pg_dump</application> has no choice
but to abort the dump.
</span>
並行ダンプを実行している時にデータベースオブジェクトに対して排他ロックを要求すると、ダンプが失敗する可能性があります。
ダンプ実行中に誰かがダンプ予定のオブジェクトを削除してそれがなくなってしまうことがないように、ワーカープロセスがダンプする予定のオブジェクトに対して<span class="application">pg_dump</span>のリーダープロセスが共有ロック(<a class="link" href="explicit-locking.html#LOCKING-TABLES" title="13.3.1. テーブルレベルロック">ACCESS SHARE</a>)を要求するのがその理由です。
その後他のクライアントがテーブルに対する排他ロックを要求すると、
そのロックは許可されませんが、リーダープロセスが共有ロックを解放することを待機するキューに保管されます。
その結果、テーブルへのその他のアクセスは許可されず、排他ロック要求の後のキューに保管されます。
これには、そのテーブルをダンプしようとする作業用プロセスも含まれます。
何らかの注意をしないと、古典的なデッドロック状態になります。
この競合を検知するために<span class="application">pg_dump</span>の作業用プロセスは<code class="literal">NOWAIT</code>オプションを使用する別の共有ロックを要求します。
作業用プロセスによる共有ロックが許可されない場合、だれかがその時に排他ロックを要求していることになり、ダンプを継続することができません。
<span class="application">pg_dump</span>には、ダンプを中断するしか選択肢がありません。
</p><p>
<span class="original">
To perform a parallel dump, the database server needs to support
synchronized snapshots, a feature that was introduced in
<productname>PostgreSQL</productname> 9.2 for primary servers and 10
for standbys. With this feature, database clients can ensure they see
the same data set even though they use different connections.
<command>pg_dump -j</command> uses multiple database connections; it
connects to the database once with the leader process and once again
for each worker job. Without the synchronized snapshot feature, the
different worker jobs wouldn't be guaranteed to see the same data in
each connection, which could lead to an inconsistent backup.
</span>
並行ダンプを実行するために、データベースサーバは同期スナップショットをサポートする必要があります。
これはプライマリサーバについては<span class="productname">PostgreSQL</span> 9.2で、スタンバイについてはバージョン10で導入された機能です。
この機能を用いれば、データベースクライアントは異なる接続を使用していたとしても、確実に同じデータセットを参照することができます。
<code class="command">pg_dump -j</code>は複数のデータベース接続を使用します。
リーダープロセスで一度、また、作業用ジョブそれぞれでも一度、データベースと接続します。
同期スナップショット機能がないと、異なる作業用ジョブがそれぞれの接続で同じデータを参照していることが保証されず、一貫性がないバックアップになってしまいます。
</p></dd><dt><span class="term"><code class="option">-n <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--schema=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
<span class="original">
Dump only schemas matching <replaceable
class="parameter">pattern</replaceable>; this selects both the
schema itself, and all its contained objects. When this option is
not specified, all non-system schemas in the target database will be
dumped. Multiple schemas can be
selected by writing multiple <option>-n</option> switches. The
<replaceable class="parameter">pattern</replaceable> parameter is
interpreted as a pattern according to the same rules used by
<application>psql</application>'s <literal>\d</literal> commands
(see <xref linkend="app-psql-patterns"/>),
so multiple schemas can also be selected by writing wildcard characters
in the pattern. When using wildcards, be careful to quote the pattern
if needed to prevent the shell from expanding the wildcards; see
<xref linkend="pg-dump-examples"/> below.
</span>
<em class="replaceable"><code>pattern</code></em>にマッチするスキーマのみをダンプします。
これはスキーマ自体とそこに含まれるオブジェクトすべてを選択します。
このオプションが指定されなければ、対象データベース内にあるシステム以外のスキーマすべてがダンプされます。
複数の<code class="option">-n</code>オプションを記述することで、複数のスキーマを選択することができます。
<em class="replaceable"><code>pattern</code></em>パラメータは<span class="application">psql</span>の<code class="literal">\d</code>コマンドと同じ規則に従うパターン(<a class="xref" href="app-psql.html#APP-PSQL-PATTERNS" title="パターン">パターン</a>参照)として解釈されます。
ですので、ワイルドカード文字をパターン内に記述することで、複数のスキーマを選択することもできます。
ワイルドカードを使用する時は、シェルがそのワイルドカードを展開しないように、必要であればパターンを引用符で括ってください。
下記の<a class="xref" href="app-pgdump.html#PG-DUMP-EXAMPLES" title="例">例</a>を参照してください。
</p><div class="note"><h3 class="title">注記</h3><p>
<span class="original">
When <option>-n</option> is specified, <application>pg_dump</application>
makes no attempt to dump any other database objects that the selected
schema(s) might depend upon. Therefore, there is no guarantee
that the results of a specific-schema dump can be successfully
restored by themselves into a clean database.
</span>
<code class="option">-n</code>が指定されると、<span class="application">pg_dump</span>は選択したスキーマ内のオブジェクトが依存する可能性がある、その他のデータベースオブジェクトのダンプを行いません。
したがって、スキーマ指定のダンプ結果を初期状態のデータベースに正常にリストアできるという保証はありません。
</p></div><div class="note"><h3 class="title">注記</h3><p>
<span class="original">
Non-schema objects such as large objects are not dumped when <option>-n</option> is
specified. You can add large objects back to the dump with the
<option>&#45;-large-objects</option> switch.
</span>
<code class="option">-n</code>が指定されると、ラージオブジェクトなどの非スキーマオブジェクトはダンプされません。
<code class="option">--large-objects</code>オプションをつけてダンプを行うことでラージオブジェクトも追加されます。
</p></div></dd><dt><span class="term"><code class="option">-N <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--exclude-schema=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
<span class="original">
Do not dump any schemas matching <replaceable
class="parameter">pattern</replaceable>. The pattern is
interpreted according to the same rules as for <option>-n</option>.
<option>-N</option> can be given more than once to exclude schemas
matching any of several patterns.
</span>
<em class="replaceable"><code>pattern</code></em>にマッチするスキーマをダンプしません。
このパターンは<code class="option">-n</code>と同様の規則に従って解釈されます。
<code class="option">-N</code>を複数指定して、複数のパターンのいずれかにマッチするスキーマを除外することができます。
</p><p>
<span class="original">
When both <option>-n</option> and <option>-N</option> are given, the behavior
is to dump just the schemas that match at least one <option>-n</option>
switch but no <option>-N</option> switches. If <option>-N</option> appears
without <option>-n</option>, then schemas matching <option>-N</option> are
excluded from what is otherwise a normal dump.
</span>
<code class="option">-n</code>と<code class="option">-N</code>の両方が指定された場合、少なくとも1つの<code class="option">-n</code>にマッチし<code class="option">-N</code>オプションにマッチしないスキーマだけがダンプされます。
<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_dump</application> issues
<command>ALTER OWNER</command> or
<command>SET SESSION AUTHORIZATION</command>
statements to set ownership of created database objects.
These statements
will fail when the script is run unless it is started by a superuser
(or the same user that owns all of the objects in the script).
To make a script that can be restored by any user, but will give
that user ownership of all the objects, specify <option>-O</option>.
</span>
オブジェクトの所有権を元のデータベースにマッチさせるためのコマンドを出力しません。
デフォルトでは、<span class="application">pg_dump</span>は、<code class="command">ALTER OWNER</code>文または<code class="command">SET SESSION AUTHORIZATION</code>文を発行して、作成したデータベースオブジェクトの所有権を設定します。
スーパーユーザ(もしくは、そのスクリプト内の全てのオブジェクトを所有するユーザ)以外のユーザがスクリプトを実行した場合、これらの文は失敗します。
任意のユーザがリストアできるスクリプトを作成するには、<code class="option">-O</code>を指定してください。
ただし、この場合は、全てのオブジェクトの所有者がリストアしたユーザとなってしまいます。
</p><p>
<span class="original">
This option is ignored when emitting an archive (non-text) output
file. For the archive formats, you can specify the option when you
call <command>pg_restore</command>.
</span>
このオプションはアーカイブ(テキストでない)出力ファイルを出力する場合には無視されます。
アーカイブ形式では、<code class="command">pg_restore</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">
Dump only the object definitions (schema), not data or statistics.
</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</option>.
</span>
このオプションは、<code class="option">--data-only</code>や<code class="option">--statistics-only</code>と一緒に使用することはできません。
これは<code class="option">--section=pre-data --section=post-data</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><p>
<span class="original">
To exclude table data for only a subset of tables in the database,
see <option>&#45;-exclude-table-data</option>.
</span>
データベース内の一部のみのテーブルのテーブルデータを除外するためには<code class="option">--exclude-table-data</code>を参照してください。
</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.
(Usually, it's better to leave this out, and instead start the
resulting script as superuser.)
</span>
トリガを無効にする場合に使用する、スーパーユーザのユーザ名を指定します。
これは<code class="option">--disable-triggers</code>を使う場合にのみ使用されます。
(通常は、このオプションを使うよりも、出力されたスクリプトをスーパーユーザ権限で実行する方が良いでしょう。)
</p></dd><dt><span class="term"><code class="option">-t <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--table=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
<span class="original">
Dump only tables with names matching
<replaceable class="parameter">pattern</replaceable>. Multiple tables
can be selected by writing multiple <option>-t</option> switches. The
<replaceable class="parameter">pattern</replaceable> parameter is
interpreted as a pattern according to the same rules used by
<application>psql</application>'s <literal>\d</literal> commands
(see <xref linkend="app-psql-patterns"/>),
so multiple tables can also be selected by writing wildcard characters
in the pattern. When using wildcards, be careful to quote the pattern
if needed to prevent the shell from expanding the wildcards; see
<xref linkend="pg-dump-examples"/> below.
</span>
<em class="replaceable"><code>pattern</code></em>にマッチする名前のテーブルのみをダンプします。
複数の<code class="option">-t</code>オプションを記述することで複数のテーブルを選択することができます。
<em class="replaceable"><code>pattern</code></em>パラメータは<span class="application">psql</span>の <code class="literal">\d</code>コマンドで使用される規則(<a class="xref" href="app-psql.html#APP-PSQL-PATTERNS" title="パターン">パターン</a>参照)と同じ規則に従うパターンとして解釈されます。
ですので、ワイルドカード文字をパターン内に記述することで、複数のテーブルを選択することもできます。
ワイルドカードを使用する時は、シェルによりそのワイルドカードを展開させないように、パターンを引用符で括ってください。
下記の<a class="xref" href="app-pgdump.html#PG-DUMP-EXAMPLES" title="例">例</a>を参照してください。
</p><p>
<span class="original">
As well as tables, this option can be used to dump the definition of matching
views, materialized views, foreign tables, and sequences. It will not dump the
contents of views or materialized views, and the contents of foreign tables will
only be dumped if the corresponding foreign server is specified with
<option>&#45;-include-foreign-data</option>.
</span>
このオプションは、テーブルだけでなく、ビュー、マテリアライズドビュー、外部テーブル、シーケンスの定義をダンプするのにも使えます。
ビューやマテリアライズドビューの内容はダンプしませんし、対応する外部サーバに<code class="option">--include-foreign-data</code>が指定されている場合にのみ、外部テーブルの内容がダンプされます。
</p><p>
<span class="original">
The <option>-n</option> and <option>-N</option> switches have no effect when
<option>-t</option> is used, because tables selected by <option>-t</option> will
be dumped regardless of those switches, and non-table objects will not
be dumped.
</span>
<code class="option">-t</code>が使用されると、<code class="option">-n</code>および<code class="option">-N</code>オプションの効果はなくなります。
<code class="option">-t</code>で選択したテーブルが、これらのオプションとは関係なくダンプされ、また、非テーブルオブジェクトはダンプされないためです。
</p><div class="note"><h3 class="title">注記</h3><p>
<span class="original">
When <option>-t</option> is specified, <application>pg_dump</application>
makes no attempt to dump any other database objects that the selected
table(s) might depend upon. Therefore, there is no guarantee
that the results of a specific-table dump can be successfully
restored by themselves into a clean database.
</span>
<code class="option">-t</code>が指定されると、<span class="application">pg_dump</span>は選択したテーブル内のオブジェクトが依存する可能性がある他のデータベースオブジェクトのダンプを行いません。
したがって、テーブル指定のダンプ結果を初期化されたデータベースに正常にリストアできるという保証はありません。
</p></div></dd><dt><span class="term"><code class="option">-T <em class="replaceable"><code>pattern</code></em></code><br /></span><span class="term"><code class="option">--exclude-table=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
<span class="original">
Do not dump any tables matching <replaceable
class="parameter">pattern</replaceable>. The pattern is
interpreted according to the same rules as for <option>-t</option>.
<option>-T</option> can be given more than once to exclude tables
matching any of several patterns.
</span>
<em class="replaceable"><code>pattern</code></em>にマッチするテーブルをダンプしません。
このパターンは<code class="option">-t</code>と同じ規則に従って解釈されます。
<code class="option">-T</code>を複数指定することで、複数のパターンのいずれかにマッチするテーブルをすべて除外させることができます。
</p><p>
<span class="original">
When both <option>-t</option> and <option>-T</option> are given, the behavior
is to dump just the tables that match at least one <option>-t</option>
switch but no <option>-T</option> switches. If <option>-T</option> appears
without <option>-t</option>, then tables matching <option>-T</option> are
excluded from what is otherwise a normal dump.
</span>
<code class="option">-t</code>と<code class="option">-T</code>の両方が指定された場合、少なくとも1つの<code class="option">-t</code>オプションにマッチし、<code class="option">-T</code>オプションにマッチしないテーブルのみがダンプされます。
<code class="option">-t</code>なしで<code class="option">-T</code>が指定された場合、通常のダンプから<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_dump</application> to output detailed object
comments and start/stop times to the dump 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_dump</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_dump</application> version and exit.
</span>
<span class="application">pg_dump</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 dumping of access privileges (grant/revoke commands).
</span>
アクセス権限(grant/revokeコマンド)のダンプを抑制します。
</p></dd><dt><span class="term"><code class="option">-Z <em class="replaceable"><code>level</code></em></code><br /></span><span class="term"><code class="option">-Z <em class="replaceable"><code>method</code></em></code>[:<em class="replaceable"><code>detail</code></em>]<br /></span><span class="term"><code class="option">--compress=<em class="replaceable"><code>level</code></em></code><br /></span><span class="term"><code class="option">--compress=<em class="replaceable"><code>method</code></em></code>[:<em class="replaceable"><code>detail</code></em>]</span></dt><dd><p>
<span class="original">
Specify the compression method and/or the compression level to use.
The compression method can be set to <literal>gzip</literal>,
<literal>lz4</literal>, <literal>zstd</literal>,
or <literal>none</literal> for no compression.
A compression detail string can optionally be specified. If the
detail string is an integer, it specifies the compression level.
Otherwise, it should be a comma-separated list of items, each of the
form <literal>keyword</literal> or <literal>keyword=value</literal>.
Currently, the supported keywords are <literal>level</literal> and
<literal>long</literal>.
</span>
使用する圧縮方式または圧縮レベル、あるいはその両方を指定します。
圧縮方式は、<code class="literal">gzip</code>、<code class="literal">lz4</code>、<code class="literal">zstd</code>に設定できます。非圧縮の場合は<code class="literal">none</code>です。
圧縮の詳細文字列は、オプションで指定できます。
詳細文字列が整数の場合は、圧縮レベルを指定します。
それ以外の場合は、<code class="literal">keyword</code>または<code class="literal">keyword=value</code>の形式のカンマで区切られた項目リストにします。
現在サポートされているキーワードは、<code class="literal">level</code>と<code class="literal">long</code>です。
</p><p>
<span class="original">
If no compression level is specified, the default compression
level will be used. If only a level is specified without mentioning
an algorithm, <literal>gzip</literal> compression will be used if
the level is greater than <literal>0</literal>, and no compression
will be used if the level is <literal>0</literal>.
</span>
圧縮レベルが指定されていない場合、デフォルトの圧縮レベルが使用されます。
アルゴリズムを指定せずにレベルのみを指定した場合、レベルが<code class="literal">0</code>より大きい場合は<code class="literal">gzip</code>圧縮が使用され、レベルが<code class="literal">0</code>の場合は圧縮が使用されません。
</p><p>
<span class="original">
For the custom and directory archive formats, this specifies compression of
individual table-data segments, and the default is to compress using
<literal>gzip</literal> at a moderate level. For plain text output,
setting a nonzero compression level causes the entire output file to be compressed,
as though it had been fed through <application>gzip</application>,
<application>lz4</application>, or <application>zstd</application>;
but the default is not to compress.
With zstd compression, <literal>long</literal> mode may improve the
compression ratio, at the cost of increased memory use.
</span>
カスタムおよびディレクトリアーカイブ形式では、これは個々のテーブルデータセグメントの圧縮を指定するもので、デフォルトでは<code class="literal">gzip</code>を使って中間レベルで圧縮されます。
平文出力では、非ゼロの圧縮レベルの指定によりあたかも<span class="application">gzip</span>、<span class="application">lz4</span>、<span class="application">zstd</span>に渡されたかのように出力ファイル全体が圧縮されます。
しかしデフォルトは圧縮無しです。
zstd圧縮では、<code class="literal">long</code>モードは、メモリ使用の増加という犠牲を払いますが、圧縮率を改善するかもしれません。
</p><p>
<span class="original">
The tar archive format currently does not support compression at all.
</span>
tarアーカイブ形式では現在圧縮を全くサポートしていません。
</p></dd><dt><span class="term"><code class="option">--binary-upgrade</code></span></dt><dd><p>
<span class="original">
This option is for use by in-place upgrade utilities. Its use
for other purposes is not recommended or supported. The
behavior of the option may change in future releases without
notice.
</span>
このオプションは現位置でのアップグレード用のユーティリティにより使用されるものです。
他の目的での使用は推奨されませんし、サポートもされません。
このオプションの動作は、将来通知することなく変更される可能性があります。
</p></dd><dt><span class="term"><code class="option">--column-inserts</code><br /></span><span class="term"><code class="option">--attribute-inserts</code></span></dt><dd><p>
<span class="original">
Dump data as <command>INSERT</command> commands with explicit
column names (<literal>INSERT INTO
<replaceable>table</replaceable>
(<replaceable>column</replaceable>, ...) VALUES
...</literal>). This will make restoration very slow; it is mainly
useful for making dumps that can be loaded into
non-<productname>PostgreSQL</productname> databases.
Any error during restoring will cause only rows that are part of the
problematic <command>INSERT</command> to be lost, rather than the
entire table contents.
</span>
明示的に列名を付けた<code class="command">INSERT</code>コマンド(<code class="literal">INSERT INTO <em class="replaceable"><code>table</code></em> (<em class="replaceable"><code>column</code></em>, ...)VALUES...</code>)としてデータをダンプします。
これによりリストアは非常に遅くなります。
主に<span class="productname">PostgreSQL</span>以外のデータベースへロード可能なダンプを作成する時に有用です。
リストア中のエラーでは、テーブルの内容がまるごと失われることはなく、問題のある<code class="command">INSERT</code>の一部の行が失われるだけです。
</p></dd><dt><span class="term"><code class="option">--disable-dollar-quoting</code></span></dt><dd><p>
<span class="original">
This option disables the use of dollar quoting for function bodies,
and forces them to be quoted using SQL standard string syntax.
</span>
このオプションは、関数本体用のドル引用符の使用を無効にし、強制的に標準SQLの文字列構文を使用した引用符付けを行います。
</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 creating a dump that includes data
but does not include schema.
It instructs <application>pg_dump</application> to include 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_dump</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 be careful to
start the resulting script as a superuser.
</span>
現在のところ、<code class="option">--disable-triggers</code>に対応するコマンドを実行するのは、スーパーユーザでなければなりません。
そのため、<code class="option">-S</code>でスーパーユーザの名前を指定するか、あるいは、可能であれば、スーパーユーザ権限でスクリプトを開始するよう注意する必要があります。
</p><p>
<span class="original">
This option is ignored when emitting an archive (non-text) output
file. For the archive formats, you can specify the option when you
call <command>pg_restore</command>.
</span>
このオプションはアーカイブ(テキストでない)出力ファイルを出力する場合には無視されます。
アーカイブ形式では、<code class="command">pg_restore</code>を呼び出す時にこのオプションを指定できます。
</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 dumping the contents of a table
which has row security. By default, <application>pg_dump</application> will set
<xref linkend="guc-row-security"/> to off, to ensure
that all data is dumped from the table. If the user does not have
sufficient privileges to bypass row security, then an error is thrown.
This parameter instructs <application>pg_dump</application> to set
<xref linkend="guc-row-security"/> to on instead, allowing the user
to dump the parts of the contents of the table that they have access to.
</span>
このオプションは、行セキュリティのあるテーブルの内容をダンプするときにのみ意味を持ちます。
デフォルトでは、<span class="application">pg_dump</span>は<a class="xref" href="runtime-config-client.html#GUC-ROW-SECURITY">row_security</a>をoffに設定し、テーブルからすべてのデータがダンプされるようにします。
ユーザが行セキュリティを無視できるだけの十分な権限を持っていない場合、エラーが発生します。
このパラメータは<span class="application">pg_dump</span>が<a class="xref" href="runtime-config-client.html#GUC-ROW-SECURITY">row_security</a>をonに設定するようにすることで、テーブルの内容のうち、ユーザがアクセスできる部分をダンプすることを可能にします。
</p><p>
<span class="original">
Note that if you use this option currently, you probably also want
the dump be in <command>INSERT</command> format, as the
<command>COPY FROM</command> during restore 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">--exclude-extension=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
<span class="original">
Do not dump any extensions matching <replaceable
class="parameter">pattern</replaceable>. The pattern is
interpreted according to the same rules as for <option>-e</option>.
<option>&#45;-exclude-extension</option> can be given more than once to exclude extensions
matching any of several patterns.
</span>
<em class="replaceable"><code>pattern</code></em>にマッチする拡張をダンプしません。
このパターンは<code class="option">-e</code>と同じ規則に従って解釈されます。
<code class="option">--exclude-extension</code>は複数回指定でき、いくつかのパターンにマッチする拡張を除外できます。
</p><p>
<span class="original">
When both <option>-e</option> and <option>&#45;-exclude-extension</option> are given, the behavior
is to dump just the extensions that match at least one <option>-e</option>
switch but no <option>&#45;-exclude-extension</option> switches. If <option>&#45;-exclude-extension</option>
appears without <option>-e</option>, then extensions matching <option>&#45;-exclude-extension</option> are
excluded from what is otherwise a normal dump.
</span>
<code class="option">-e</code>と<code class="option">--exclude-extension</code>の両方が指定された場合、少なくとも1つの<code class="option">-e</code>にマッチし<code class="option">--exclude-extension</code>オプションにマッチしない拡張だけがダンプされます。
<code class="option">--exclude-extension</code>が<code class="option">-e</code>なしで現れた場合、<code class="option">--exclude-extension</code>にマッチする拡張は通常のダンプから除外されます。
</p></dd><dt><span class="term"><code class="option">--exclude-table-and-children=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
<span class="original">
This is the same as
the <option>-T</option>/<option>&#45;-exclude-table</option> option,
except that it also excludes any partitions or inheritance child
tables of the table(s) matching the
<replaceable class="parameter">pattern</replaceable>.
</span>
これは<code class="option">-T</code>/<code class="option">--exclude-table</code>オプションと同じですが、<em class="replaceable"><code>pattern</code></em>にマッチするパーティションや継承の子テーブルもすべて除外する点が異なります。
</p></dd><dt><span class="term"><code class="option">--exclude-table-data=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
<span class="original">
Do not dump data for any tables matching <replaceable
class="parameter">pattern</replaceable>. The pattern is
interpreted according to the same rules as for <option>-t</option>.
<option>&#45;-exclude-table-data</option> can be given more than once to
exclude tables matching any of several patterns. This option is
useful when you need the definition of a particular table even
though you do not need the data in it.
</span>
<em class="replaceable"><code>pattern</code></em>にマッチするすべてのテーブルのデータをダンプしません。
パターンは<code class="option">-t</code>用の規則と同じ規則にしたがって解釈されます。
複数のパターンのいずれかにマッチするテーブルを除外することができるように、<code class="option">--exclude-table-data</code>を複数回与えることができます。
このオプションは、特定のテーブルに関してデータを格納する必要はないがテーブル定義は必要である場合に有用です。
</p><p>
<span class="original">
To exclude data for all tables in the database, see <option>&#45;-schema-only</option>
or <option>&#45;-statistics-only</option>.
</span>
データベース内のすべてのテーブルに関してデータを除外するためには、<code class="option">--schema-only</code>または<code class="option">--statistics-only</code>を参照してください。
</p></dd><dt><span class="term"><code class="option">--exclude-table-data-and-children=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
<span class="original">
This is the same as the <option>&#45;-exclude-table-data</option> option,
except that it also excludes data of any partitions or inheritance
child tables of the table(s) matching the
<replaceable class="parameter">pattern</replaceable>.
</span>
これは<code class="option">--exclude-table-data</code>オプションと同じですが、<em class="replaceable"><code>pattern</code></em>にマッチするパーティションや継承の子テーブルのデータも除外する点が異なります。
</p></dd><dt><span class="term"><code class="option">--extra-float-digits=<em class="replaceable"><code>ndigits</code></em></code></span></dt><dd><p>
<span class="original">
Use the specified value of <option>extra_float_digits</option> when dumping
floating-point data, instead of the maximum available precision.
Routine dumps made for backup purposes should not use this option.
</span>
浮動小数点データをダンプする時に、利用できる最大の精度の代わりに、<code class="option">extra_float_digits</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 to include
or exclude from the dump. The patterns are interpreted according to the
same rules as the corresponding options:
<option>-t</option>/<option>&#45;-table</option>,
<option>&#45;-table-and-children</option>,
<option>-T</option>/<option>&#45;-exclude-table</option>, and
<option>&#45;-exclude-table-and-children</option> for tables,
<option>-n</option>/<option>&#45;-schema</option> and
<option>-N</option>/<option>&#45;-exclude-schema</option> for schemas,
<option>&#45;-include-foreign-data</option> for data on foreign servers,
<option>&#45;-exclude-table-data</option> and
<option>&#45;-exclude-table-data-and-children</option> for table data, and
<option>-e</option>/<option>&#45;-extension</option> and
<option>&#45;-exclude-extension</option> for extensions.
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">-t</code>/<code class="option">--table</code>、<code class="option">--table-and-children</code>、<code class="option">-T</code>/<code class="option">--exclude-table</code>、<code class="option">--exclude-table-and-children</code>、スキーマの場合は<code class="option">-n</code>/<code class="option">--schema</code>、<code class="option">-N</code>/<code class="option">--exclude-schema</code>、外部サーバのデータの場合は<code class="option">--include-foreign-data</code>、テーブルデータの場合は<code class="option">--exclude-table-data</code>と<code class="option">--exclude-table-data-and-children</code>、拡張の場合は<code class="option">-e</code>/<code class="option">--extension</code>と<code class="option">--exclude-extension</code>です。
<code class="literal">STDIN</code>から読み取るには、ファイル名として<code class="filename">-</code>を使用します。
<code class="option">--filter</code>オプションは、オブジェクトを含めるまたは除外するために、上記のオプションとともに指定でき、更に複数のファイルをフィルタするために複数回指定することもできます。
</p><p>
<span class="original">
The file lists one object pattern per row, with the following format:
</span>
ファイルには、オブジェクトパターンが1行に1つずつリストされ、次の形式になります。
</p><pre class="synopsis">
{ include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } <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>extension</literal>: extensions. This works like the
<option>-e</option>/<option>&#45;-extension</option> or
<option>&#45;-exclude-extension</option> option.
</span>
<code class="literal">extension</code>:拡張。
これは<code class="option">-e</code>/<code class="option">--extension</code>または<code class="option">--exclude-extension</code>オプションと同様に機能します。
</p></li><li class="listitem"><p>
<span class="original">
<literal>foreign_data</literal>: data on foreign servers. This works like
the <option>&#45;-include-foreign-data</option> option. This keyword can
only be used with the <literal>include</literal> keyword.
</span>
<code class="literal">foreign_data</code>:外部サーバ上のデータ。
これは<code class="option">--include-foreign-data</code>オプションと同様に機能します。
このキーワードは<code class="literal">include</code>キーワードと一緒にのみ使用できます。
</p></li><li class="listitem"><p>
<span class="original">
<literal>table</literal>: tables. This works like the
<option>-t</option>/<option>&#45;-table</option> or
<option>-T</option>/<option>&#45;-exclude-table</option> option.
</span>
<code class="literal">table</code>:テーブル。
これは<code class="option">-t</code>/<code class="option">--table</code>または<code class="option">-T</code>/<code class="option">--exclude-table</code>オプションと同様に機能します。
</p></li><li class="listitem"><p>
<span class="original">
<literal>table_and_children</literal>: tables including any partitions
or inheritance child tables. This works like the
<option>&#45;-table-and-children</option> or
<option>&#45;-exclude-table-and-children</option> option.
</span>
<code class="literal">table_and_children</code>:任意のパーティションまたは継承の子テーブルを含むテーブル。
これは<code class="option">--table-and-children</code>または<code class="option">--exclude-table-and-children</code>オプションと同様に機能します。
</p></li><li class="listitem"><p>
<span class="original">
<literal>table_data</literal>: table data of any tables matching
<replaceable>pattern</replaceable>. This works like the
<option>&#45;-exclude-table-data</option> option. This keyword can only
be used with the <literal>exclude</literal> keyword.
</span>
<code class="literal">table_data</code>:<em class="replaceable"><code>pattern</code></em>にマッチする任意のテーブルのテーブルデータ。
これは<code class="option">--exclude-table-data</code>オプションと同様に機能します。
このキーワードは<code class="literal">exclude</code>キーワードと一緒にのみ使用できます。
</p></li><li class="listitem"><p>
<span class="original">
<literal>table_data_and_children</literal>: table data of any tables
matching <replaceable>pattern</replaceable> as well as any partitions
or inheritance children of the table(s). This works like the
<option>&#45;-exclude-table-data-and-children</option> option. This
keyword can only be used with the <literal>exclude</literal> keyword.
</span>
<code class="literal">table_data_and_children</code>:<em class="replaceable"><code>pattern</code></em>にマッチする任意のテーブルのテーブルデータおよびテーブルのすべてのパーティションまたは継承する子テーブルのデータ。
これは<code class="option">--exclude-table-data-and-children</code>オプションと同様に機能します。
このキーワードは<code class="literal">exclude</code>キーワードと一緒にのみ使用できます。
</p></li><li class="listitem"><p>
<span class="original">
<literal>schema</literal>: schemas. This works like the
<option>-n</option>/<option>&#45;-schema</option> or
<option>-N</option>/<option>&#45;-exclude-schema</option> option.
</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></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><p>
<span class="original">
Example files are listed below in the <xref linkend="pg-dump-examples"/>
section.
</span>
例は<a class="xref" href="app-pgdump.html#PG-DUMP-EXAMPLES" 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">--include-foreign-data=<em class="replaceable"><code>foreignserver</code></em></code></span></dt><dd><p>
<span class="original">
Dump the data for any foreign table with a foreign server
matching <replaceable class="parameter">foreignserver</replaceable>
pattern. Multiple foreign servers can be selected by writing multiple
<option>&#45;-include-foreign-data</option> switches.
Also, the <replaceable class="parameter">foreignserver</replaceable> parameter is
interpreted as a pattern according to the same rules used by
<application>psql</application>'s <literal>\d</literal> commands
(see <xref linkend="app-psql-patterns"/>),
so multiple foreign servers can also be selected by writing wildcard characters
in the pattern. When using wildcards, be careful to quote the pattern
if needed to prevent the shell from expanding the wildcards; see
<xref linkend="pg-dump-examples"/> below.
The only exception is that an empty pattern is disallowed.
</span>
<em class="replaceable"><code>foreignserver</code></em>パターンとマッチする外部サーバの外部テーブルのデータをダンプします。
複数の<code class="option">--include-foreign-data</code>スイッチを書くことで、複数の外部サーバを選択できます。
また、<em class="replaceable"><code>foreignserver</code></em>パラメータは<span class="application">psql</span>の<code class="literal">\d</code>コマンドで使われているのと同じ規則に従うパターンとして解釈されます(<a class="xref" href="app-psql.html#APP-PSQL-PATTERNS" title="パターン">パターン</a>を参照してください)ので、パターンにワイルドカード文字を書くことで複数の外部サーバを選択することもできます。
ワイルドカードを使う時は、シェルがワイルドカードを展開しないよう必要ならパターンを引用符で囲むことに注意してください。下記の<a class="xref" href="app-pgdump.html#PG-DUMP-EXAMPLES" title="例">例</a>を参照してください。
唯一の例外は空のパターンが許されていないことです。
</p><div class="note"><h3 class="title">注記</h3><p>
<span class="original">
Using wildcards in <option>&#45;-include-foreign-data</option> may result
in access to unexpected foreign servers. Also, to use this option securely,
make sure that the named server must have a trusted owner.