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

Commita51e54c

Browse files
author
Neil Conway
committed
Document a limitation of COPY's new CSV mode. Doc patch from Andrew
Dunstan, editorializing by Neil Conway.
1 parentb25d23e commita51e54c

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

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

Lines changed: 19 additions & 13 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.58 2004/11/15 06:32:15 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/copy.sgml,v 1.59 2004/11/17 02:50:06 neilc Exp $
33
PostgreSQL documentation
44
-->
55

@@ -433,13 +433,13 @@ COPY <replaceable class="parameter">tablename</replaceable> [ ( <replaceable cla
433433
</para>
434434

435435
<para>
436-
It is strongly recommended that applications generating COPY data convert
436+
It is strongly recommended that applications generating<command>COPY</command> data convert
437437
data newlines and carriage returns to the <literal>\n</> and
438438
<literal>\r</> sequences respectively. At present it is
439439
possible to represent a data carriage return by a backslash and carriage
440440
return, and to represent a data newline by a backslash and newline.
441441
However, these representations might not be accepted in future releases.
442-
They are also highly vulnerable to corruption if the COPY file is
442+
They are also highly vulnerable to corruption if the<command>COPY</command> file is
443443
transferred across different machines (for example, from Unix to Windows
444444
or vice versa).
445445
</para>
@@ -484,23 +484,29 @@ COPY <replaceable class="parameter">tablename</replaceable> [ ( <replaceable cla
484484

485485
<para>
486486
In general, the <literal>CSV</> format has no way to distinguish a
487-
<literal>NULL</> from an empty string.
488-
<productname>PostgreSQL</productname>'s COPY handles this by
489-
quoting. A <literal>NULL</> is output as the <literal>NULL</> string
490-
and is not quoted, while a data value matching the <literal>NULL</> string
491-
is quoted. Therefore, using the default settings, a <literal>NULL</> is
492-
written as an unquoted empty string, while an empty string is
493-
written with double quotes (<literal>""</>). Reading values follows
494-
similar rules. You can use <literal>FORCE NOT NULL</> to prevent <literal>NULL</>
495-
input comparisons for specific columns.
487+
<literal>NULL</> value from an empty string.
488+
<productname>PostgreSQL</>'s <command>COPY</> handles this by
489+
quoting. A <literal>NULL</> is output as the <literal>NULL</>
490+
string and is not quoted, while a data value matching the
491+
<literal>NULL</> string is quoted. Therefore, using the default
492+
settings, a <literal>NULL</> is written as an unquoted empty
493+
string, while an empty string is written with double quotes
494+
(<literal>""</>). Reading values follows similar rules. You can
495+
use <literal>FORCE NOT NULL</> to prevent <literal>NULL</> input
496+
comparisons for specific columns.
496497
</para>
497498

498499
<note>
499500
<para>
500501
CSV mode will both recognize and produce CSV files with quoted
501502
values containing embedded carriage returns and line feeds. Thus
502503
the files are not strictly one line per table row like text-mode
503-
files.
504+
files. However, <productname>PostgreSQL</productname> will reject
505+
<command>COPY</command> input if any fields contain embedded line
506+
end character sequences that do not match the line ending
507+
convention used in the CSV file itself. It is generally safer to
508+
import data containing embedded line end characters using the
509+
text or binary formats rather than CSV.
504510
</para>
505511
</note>
506512

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp