Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita2367f8

Browse files
committed
Add a note warning that COPY BINARY is very datatype-specific.
Per a complaint from Gordon Shannon.
1 parente3b3878 commita2367f8

File tree

1 file changed

+35
-31
lines changed

1 file changed

+35
-31
lines changed

‎doc/src/sgml/ref/copy.sgml

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/copy.sgml,v 1.86 2009/07/25 00:07:10 adunstan Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/copy.sgml,v 1.87 2009/09/05 23:58:01 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -24,30 +24,30 @@ PostgreSQL documentation
2424
<synopsis>
2525
COPY <replaceable class="parameter">tablename</replaceable> [ ( <replaceable class="parameter">column</replaceable> [, ...] ) ]
2626
FROM { '<replaceable class="parameter">filename</replaceable>' | STDIN }
27-
[ [ WITH ]
27+
[ [ WITH ]
2828
[ BINARY ]
2929
[ OIDS ]
3030
[ DELIMITER [ AS ] '<replaceable class="parameter">delimiter</replaceable>' ]
3131
[ NULL [ AS ] '<replaceable class="parameter">null string</replaceable>' ]
3232
[ CSV [ HEADER ]
33-
[ QUOTE [ AS ] '<replaceable class="parameter">quote</replaceable>' ]
33+
[ QUOTE [ AS ] '<replaceable class="parameter">quote</replaceable>' ]
3434
[ ESCAPE [ AS ] '<replaceable class="parameter">escape</replaceable>' ]
3535
[ FORCE NOT NULL <replaceable class="parameter">column</replaceable> [, ...] ]
3636

3737
COPY { <replaceable class="parameter">tablename</replaceable> [ ( <replaceable class="parameter">column</replaceable> [, ...] ) ] | ( <replaceable class="parameter">query</replaceable> ) }
3838
TO { '<replaceable class="parameter">filename</replaceable>' | STDOUT }
39-
[ [ WITH ]
39+
[ [ WITH ]
4040
[ BINARY ]
4141
[ OIDS ]
4242
[ DELIMITER [ AS ] '<replaceable class="parameter">delimiter</replaceable>' ]
4343
[ NULL [ AS ] '<replaceable class="parameter">null string</replaceable>' ]
4444
[ CSV [ HEADER ]
45-
[ QUOTE [ AS ] '<replaceable class="parameter">quote</replaceable>' ]
45+
[ QUOTE [ AS ] '<replaceable class="parameter">quote</replaceable>' ]
4646
[ ESCAPE [ AS ] '<replaceable class="parameter">escape</replaceable>' ]
4747
[ FORCE QUOTE { <replaceable class="parameter">column</replaceable> [, ...] | * } ]
4848
</synopsis>
4949
</refsynopsisdiv>
50-
50+
5151
<refsect1>
5252
<title>Description</title>
5353

@@ -79,7 +79,7 @@ COPY { <replaceable class="parameter">tablename</replaceable> [ ( <replaceable c
7979
client and the server.
8080
</para>
8181
</refsect1>
82-
82+
8383
<refsect1>
8484
<title>Parameters</title>
8585

@@ -215,7 +215,7 @@ COPY { <replaceable class="parameter">tablename</replaceable> [ ( <replaceable c
215215
<listitem>
216216
<para>
217217
Specifies that the file contains a header line with the names of each
218-
column in the file. On output, the first line contains the column
218+
column in the file. On output, the first line contains the column
219219
names from the table, and on input, the first line is ignored.
220220
</para>
221221
</listitem>
@@ -249,7 +249,7 @@ COPY { <replaceable class="parameter">tablename</replaceable> [ ( <replaceable c
249249
In <literal>CSV</> <command>COPY TO</> mode, forces quoting to be
250250
used for all non-<literal>NULL</> values in each specified column.
251251
<literal>NULL</> output is never quoted. If <literal>*</> is specified,
252-
non-<literal>NULL</> values for all columns of the table will be
252+
non-<literal>NULL</> values for all columns of the table will be
253253
quoted.
254254
</para>
255255
</listitem>
@@ -300,6 +300,10 @@ COPY <replaceable class="parameter">count</replaceable>
300300
somewhat faster than the normal text mode, but a binary-format
301301
file is less portable across machine architectures and
302302
<productname>PostgreSQL</productname> versions.
303+
Also, the binary format is very data type specific; for example
304+
it will not work to output binary data from a <type>smallint</> column
305+
and read it into an <type>integer</> column, even though that would work
306+
fine in text format.
303307
</para>
304308

305309
<para>
@@ -379,7 +383,7 @@ COPY <replaceable class="parameter">count</replaceable>
379383
</para>
380384

381385
</refsect1>
382-
386+
383387
<refsect1>
384388
<title>File Formats</title>
385389

@@ -479,7 +483,7 @@ COPY <replaceable class="parameter">count</replaceable>
479483
</tgroup>
480484
</informaltable>
481485

482-
Presently, <command>COPY TO</command> will never emit an octal or
486+
Presently, <command>COPY TO</command> will never emit an octal or
483487
hex-digits backslash sequence, but it does use the other sequences
484488
listed above for those control characters.
485489
</para>
@@ -498,15 +502,15 @@ COPY <replaceable class="parameter">count</replaceable>
498502
data newlines and carriage returns to the <literal>\n</> and
499503
<literal>\r</> sequences respectively. At present it is
500504
possible to represent a data carriage return by a backslash and carriage
501-
return, and to represent a data newline by a backslash and newline.
505+
return, and to represent a data newline by a backslash and newline.
502506
However, these representations might not be accepted in future releases.
503507
They are also highly vulnerable to corruption if the <command>COPY</command> file is
504508
transferred across different machines (for example, from Unix to Windows
505509
or vice versa).
506510
</para>
507511

508512
<para>
509-
<command>COPY TO</command> will terminate each row with a Unix-style
513+
<command>COPY TO</command> will terminate each row with a Unix-style
510514
newline (<quote><literal>\n</></>). Servers running on Microsoft Windows instead
511515
output carriage return/newline (<quote><literal>\r\n</></>), but only for
512516
<command>COPY</> to a server file; for consistency across platforms,
@@ -543,7 +547,7 @@ COPY <replaceable class="parameter">count</replaceable>
543547
non-<literal>NULL</> values in specific columns.
544548
</para>
545549

546-
<para>
550+
<para>
547551
The <literal>CSV</> format has no standard way to distinguish a
548552
<literal>NULL</> value from an empty string.
549553
<productname>PostgreSQL</>'s <command>COPY</> handles this by
@@ -557,28 +561,28 @@ COPY <replaceable class="parameter">count</replaceable>
557561
comparisons for specific columns.
558562
</para>
559563

560-
<para>
564+
<para>
561565
Because backslash is not a special character in the <literal>CSV</>
562566
format, <literal>\.</>, the end-of-data marker, could also appear
563567
as a data value. To avoid any misinterpretation, a <literal>\.</>
564-
data value appearing as a lone entry on a line is automatically
565-
quoted on output, and on input, if quoted, is not interpreted as the
568+
data value appearing as a lone entry on a line is automatically
569+
quoted on output, and on input, if quoted, is not interpreted as the
566570
end-of-data marker. If you are loading a file created by another
567-
application that has a single unquoted column and might have a
568-
value of <literal>\.</>, you might need to quote that value in the
571+
application that has a single unquoted column and might have a
572+
value of <literal>\.</>, you might need to quote that value in the
569573
input file.
570574
</para>
571575

572576
<note>
573577
<para>
574-
In <literal>CSV</> mode, all characters are significant. A quoted value
575-
surrounded by white space, or any characters other than
576-
<literal>DELIMITER</>, will include those characters. This can cause
577-
errors ifyou import data from a system that pads <literal>CSV</>
578-
lines with white space out to some fixed width. If such a situation
579-
arises you might need to preprocess the <literal>CSV</> file to remove
580-
the trailing white space, before importing the data into
581-
<productname>PostgreSQL</>.
578+
In <literal>CSV</> mode, all characters are significant. A quoted value
579+
surrounded by white space, or any characters other than
580+
<literal>DELIMITER</>, will include those characters. This can cause
581+
errors if you import data from a system that pads <literal>CSV</>
582+
lines with white space out to some fixed width. If such a situation
583+
arises you might need to preprocess the <literal>CSV</> file to remove
584+
the trailing white space, before importing the data into
585+
<productname>PostgreSQL</>.
582586
</para>
583587
</note>
584588

@@ -600,7 +604,7 @@ COPY <replaceable class="parameter">count</replaceable>
600604
programs cannot process.
601605
</para>
602606
</note>
603-
607+
604608
</refsect2>
605609

606610
<refsect2>
@@ -747,7 +751,7 @@ OIDs to be shown as null if that ever proves desirable.
747751
</refsect3>
748752
</refsect2>
749753
</refsect1>
750-
754+
751755
<refsect1>
752756
<title>Examples</title>
753757

@@ -806,10 +810,10 @@ ZW ZIMBABWE
806810
</programlisting>
807811
</para>
808812
</refsect1>
809-
813+
810814
<refsect1>
811815
<title>Compatibility</title>
812-
816+
813817
<para>
814818
There is no <command>COPY</command> statement in the SQL standard.
815819
</para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp