1
1
<!--
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 $
3
3
PostgreSQL documentation
4
4
-->
5
5
@@ -24,30 +24,30 @@ PostgreSQL documentation
24
24
<synopsis>
25
25
COPY <replaceable class="parameter">tablename</replaceable> [ ( <replaceable class="parameter">column</replaceable> [, ...] ) ]
26
26
FROM { '<replaceable class="parameter">filename</replaceable>' | STDIN }
27
- [ [ WITH ]
27
+ [ [ WITH ]
28
28
[ BINARY ]
29
29
[ OIDS ]
30
30
[ DELIMITER [ AS ] '<replaceable class="parameter">delimiter</replaceable>' ]
31
31
[ NULL [ AS ] '<replaceable class="parameter">null string</replaceable>' ]
32
32
[ CSV [ HEADER ]
33
- [ QUOTE [ AS ] '<replaceable class="parameter">quote</replaceable>' ]
33
+ [ QUOTE [ AS ] '<replaceable class="parameter">quote</replaceable>' ]
34
34
[ ESCAPE [ AS ] '<replaceable class="parameter">escape</replaceable>' ]
35
35
[ FORCE NOT NULL <replaceable class="parameter">column</replaceable> [, ...] ]
36
36
37
37
COPY { <replaceable class="parameter">tablename</replaceable> [ ( <replaceable class="parameter">column</replaceable> [, ...] ) ] | ( <replaceable class="parameter">query</replaceable> ) }
38
38
TO { '<replaceable class="parameter">filename</replaceable>' | STDOUT }
39
- [ [ WITH ]
39
+ [ [ WITH ]
40
40
[ BINARY ]
41
41
[ OIDS ]
42
42
[ DELIMITER [ AS ] '<replaceable class="parameter">delimiter</replaceable>' ]
43
43
[ NULL [ AS ] '<replaceable class="parameter">null string</replaceable>' ]
44
44
[ CSV [ HEADER ]
45
- [ QUOTE [ AS ] '<replaceable class="parameter">quote</replaceable>' ]
45
+ [ QUOTE [ AS ] '<replaceable class="parameter">quote</replaceable>' ]
46
46
[ ESCAPE [ AS ] '<replaceable class="parameter">escape</replaceable>' ]
47
47
[ FORCE QUOTE { <replaceable class="parameter">column</replaceable> [, ...] | * } ]
48
48
</synopsis>
49
49
</refsynopsisdiv>
50
-
50
+
51
51
<refsect1>
52
52
<title>Description</title>
53
53
@@ -79,7 +79,7 @@ COPY { <replaceable class="parameter">tablename</replaceable> [ ( <replaceable c
79
79
client and the server.
80
80
</para>
81
81
</refsect1>
82
-
82
+
83
83
<refsect1>
84
84
<title>Parameters</title>
85
85
@@ -215,7 +215,7 @@ COPY { <replaceable class="parameter">tablename</replaceable> [ ( <replaceable c
215
215
<listitem>
216
216
<para>
217
217
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
219
219
names from the table, and on input, the first line is ignored.
220
220
</para>
221
221
</listitem>
@@ -249,7 +249,7 @@ COPY { <replaceable class="parameter">tablename</replaceable> [ ( <replaceable c
249
249
In <literal>CSV</> <command>COPY TO</> mode, forces quoting to be
250
250
used for all non-<literal>NULL</> values in each specified column.
251
251
<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
253
253
quoted.
254
254
</para>
255
255
</listitem>
@@ -300,6 +300,10 @@ COPY <replaceable class="parameter">count</replaceable>
300
300
somewhat faster than the normal text mode, but a binary-format
301
301
file is less portable across machine architectures and
302
302
<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.
303
307
</para>
304
308
305
309
<para>
@@ -379,7 +383,7 @@ COPY <replaceable class="parameter">count</replaceable>
379
383
</para>
380
384
381
385
</refsect1>
382
-
386
+
383
387
<refsect1>
384
388
<title>File Formats</title>
385
389
@@ -479,7 +483,7 @@ COPY <replaceable class="parameter">count</replaceable>
479
483
</tgroup>
480
484
</informaltable>
481
485
482
- Presently, <command>COPY TO</command> will never emit an octal or
486
+ Presently, <command>COPY TO</command> will never emit an octal or
483
487
hex-digits backslash sequence, but it does use the other sequences
484
488
listed above for those control characters.
485
489
</para>
@@ -498,15 +502,15 @@ COPY <replaceable class="parameter">count</replaceable>
498
502
data newlines and carriage returns to the <literal>\n</> and
499
503
<literal>\r</> sequences respectively. At present it is
500
504
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.
502
506
However, these representations might not be accepted in future releases.
503
507
They are also highly vulnerable to corruption if the <command>COPY</command> file is
504
508
transferred across different machines (for example, from Unix to Windows
505
509
or vice versa).
506
510
</para>
507
511
508
512
<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
510
514
newline (<quote><literal>\n</></>). Servers running on Microsoft Windows instead
511
515
output carriage return/newline (<quote><literal>\r\n</></>), but only for
512
516
<command>COPY</> to a server file; for consistency across platforms,
@@ -543,7 +547,7 @@ COPY <replaceable class="parameter">count</replaceable>
543
547
non-<literal>NULL</> values in specific columns.
544
548
</para>
545
549
546
- <para>
550
+ <para>
547
551
The <literal>CSV</> format has no standard way to distinguish a
548
552
<literal>NULL</> value from an empty string.
549
553
<productname>PostgreSQL</>'s <command>COPY</> handles this by
@@ -557,28 +561,28 @@ COPY <replaceable class="parameter">count</replaceable>
557
561
comparisons for specific columns.
558
562
</para>
559
563
560
- <para>
564
+ <para>
561
565
Because backslash is not a special character in the <literal>CSV</>
562
566
format, <literal>\.</>, the end-of-data marker, could also appear
563
567
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
566
570
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
569
573
input file.
570
574
</para>
571
575
572
576
<note>
573
577
<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 if you 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</>.
582
586
</para>
583
587
</note>
584
588
@@ -600,7 +604,7 @@ COPY <replaceable class="parameter">count</replaceable>
600
604
programs cannot process.
601
605
</para>
602
606
</note>
603
-
607
+
604
608
</refsect2>
605
609
606
610
<refsect2>
@@ -747,7 +751,7 @@ OIDs to be shown as null if that ever proves desirable.
747
751
</refsect3>
748
752
</refsect2>
749
753
</refsect1>
750
-
754
+
751
755
<refsect1>
752
756
<title>Examples</title>
753
757
@@ -806,10 +810,10 @@ ZW ZIMBABWE
806
810
</programlisting>
807
811
</para>
808
812
</refsect1>
809
-
813
+
810
814
<refsect1>
811
815
<title>Compatibility</title>
812
-
816
+
813
817
<para>
814
818
There is no <command>COPY</command> statement in the SQL standard.
815
819
</para>
0 commit comments