3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "COPY" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 COPY \- copy data between a file and a table
35 COPY \fItable_name\fR [ ( \fIcolumn_name\fR [, \&.\&.\&.] ) ]
36 FROM { \*(Aq\fIfilename\fR\*(Aq | PROGRAM \*(Aq\fIcommand\fR\*(Aq | STDIN }
37 [ [ WITH ] ( \fIoption\fR [, \&.\&.\&.] ) ]
38 [ WHERE \fIcondition\fR ]
40 COPY { \fItable_name\fR [ ( \fIcolumn_name\fR [, \&.\&.\&.] ) ] | ( \fIquery\fR ) }
41 TO { \*(Aq\fIfilename\fR\*(Aq | PROGRAM \*(Aq\fIcommand\fR\*(Aq | STDOUT }
42 [ [ WITH ] ( \fIoption\fR [, \&.\&.\&.] ) ]
44 where \fIoption\fR can be one of:
46 FORMAT \fIformat_name\fR
47 FREEZE [ \fIboolean\fR ]
48 DELIMITER \*(Aq\fIdelimiter_character\fR\*(Aq
49 NULL \*(Aq\fInull_string\fR\*(Aq
50 DEFAULT \*(Aq\fIdefault_string\fR\*(Aq
51 HEADER [ \fIboolean\fR | MATCH ]
52 QUOTE \*(Aq\fIquote_character\fR\*(Aq
53 ESCAPE \*(Aq\fIescape_character\fR\*(Aq
54 FORCE_QUOTE { ( \fIcolumn_name\fR [, \&.\&.\&.] ) | * }
55 FORCE_NOT_NULL { ( \fIcolumn_name\fR [, \&.\&.\&.] ) | * }
56 FORCE_NULL { ( \fIcolumn_name\fR [, \&.\&.\&.] ) | * }
57 ON_ERROR \fIerror_action\fR
58 REJECT_LIMIT \fImaxerror\fR
59 ENCODING \*(Aq\fIencoding_name\fR\*(Aq
60 LOG_VERBOSITY \fIverbosity\fR
67 tables and standard file\-system files\&.
69 copies the contents of a table
75 a file to a table (appending the data to whatever is in the table already)\&.
77 can also copy the results of a
81 If a column list is specified,
83 copies only the data in the specified columns to the file\&. For
84 \fBCOPY FROM\fR, each field in the file is inserted, in order, into the specified column\&. Table columns not specified in the
86 column list will receive their default values\&.
89 with a file name instructs the
91 server to directly read from or write to a file\&. The file must be accessible by the
93 user (the user ID the server runs as) and the name must be specified from the viewpoint of the server\&. When
95 is specified, the server executes the given command and reads from the standard output of the program, or writes to the standard input of the program\&. The command must be specified from the viewpoint of the server, and be executable by the
101 is specified, data is transmitted via the connection between the client and the server\&.
105 will report its progress in the
106 pg_stat_progress_copy
113 will fail if it encounters an error during processing\&. For use cases where a best\-effort attempt at loading the entire file is desired, the
115 clause can be used to specify some other behavior\&.
120 The name (optionally schema\-qualified) of an existing table\&.
125 An optional list of columns to be copied\&. If no column list is specified, all columns of the table except generated columns will be copied\&.
137 command whose results are to be copied\&. Note that parentheses are required around the query\&.
146 clause must be provided, and the target relation must not have a conditional rule, nor an
150 rule that expands to multiple statements\&.
155 The path name of the input or output file\&. An input file name can be an absolute or relative path, but an output file name must be an absolute path\&. Windows users might need to use an
157 string and double any backslashes used in the path name\&.
162 A command to execute\&. In
163 \fBCOPY FROM\fR, the input is read from standard output of the command, and in
164 \fBCOPY TO\fR, the output is written to the standard input of the command\&.
166 Note that the command is invoked by the shell, so if you need to pass any arguments that come from an untrusted source, you must be careful to strip or escape any special characters that might have a special meaning for the shell\&. For security reasons, it is best to use a fixed command string, or at least avoid including any user input in it\&.
171 Specifies that input comes from the client application\&.
176 Specifies that output goes to the client application\&.
181 Specifies whether the selected option should be turned on or off\&. You can write
185 to enable the option, and
191 value can also be omitted, in which case
198 Selects the data format to be read or written:
201 (Comma Separated Values), or
202 binary\&. The default is
210 Requests copying the data with rows already frozen, just as they would be after running the
212 command\&. This is intended as a performance option for initial data loading\&. Rows will be frozen only if the table being loaded has been created or truncated in the current subtransaction, there are no cursors open and there are no older snapshots held by this transaction\&. It is currently not possible to perform a
214 on a partitioned table or foreign table\&. This option is only allowed in
217 Note that all other sessions will immediately be able to see the data once it has been successfully loaded\&. This violates the normal rules of MVCC visibility and users should be aware of the potential problems this might cause\&.
222 Specifies the character that separates columns within each row (line) of the file\&. The default is a tab character in text format, a comma in
224 format\&. This must be a single one\-byte character\&. This option is not allowed when using
231 Specifies the string that represents a null value\&. The default is
233 (backslash\-N) in text format, and an unquoted empty string in
235 format\&. You might prefer an empty string even in text format for cases where you don\*(Aqt want to distinguish nulls from empty strings\&. This option is not allowed when using
243 .nr an-no-space-flag 1
251 \fBCOPY FROM\fR, any data item that matches this string will be stored as a null value, so you should make sure that you use the same string as you used with
259 Specifies the string that represents a default value\&. Each time the string is found in the input file, the default value of the corresponding column will be used\&. This option is allowed only in
260 \fBCOPY FROM\fR, and only when not using
267 Specifies that the file contains a header line with the names of each column in the file\&. On output, the first line contains the column names from the table\&. On input, the first line is discarded when this option is set to
269 (or equivalent Boolean value)\&. If this option is set to
270 MATCH, the number and names of the columns in the header line must match the actual column names of the table, in order; otherwise an error is raised\&. This option is not allowed when using
274 option is only valid for
281 Specifies the quoting character to be used when a data value is quoted\&. The default is double\-quote\&. This must be a single one\-byte character\&. This option is allowed only when using
288 Specifies the character that should appear before a data character that matches the
290 value\&. The default is the same as the
292 value (so that the quoting character is doubled if it appears in the data)\&. This must be a single one\-byte character\&. This option is allowed only when using
299 Forces quoting to be used for all non\-NULL
300 values in each specified column\&.
302 output is never quoted\&. If
304 is specified, non\-NULL
305 values will be quoted in all columns\&. This option is allowed only in
306 \fBCOPY TO\fR, and only when using
313 Do not match the specified columns\*(Aq values against the null string\&. In the default case where the null string is empty, this means that empty values will be read as zero\-length strings rather than nulls, even when they are not quoted\&. If
315 is specified, the option will be applied to all columns\&. This option is allowed only in
316 \fBCOPY FROM\fR, and only when using
323 Match the specified columns\*(Aq values against the null string, even if it has been quoted, and if a match is found set the value to
324 NULL\&. In the default case where the null string is empty, this converts a quoted empty string into NULL\&. If
326 is specified, the option will be applied to all columns\&. This option is allowed only in
327 \fBCOPY FROM\fR, and only when using
334 Specifies how to behave when encountering an error converting a column\*(Aqs input value into its data type\&. An
338 means fail the command, while
340 means discard the input row and continue with the next one\&. The default is
345 option is applicable only for
356 message containing the ignored row count is emitted at the end of the
358 if at least one row was discarded\&. When
363 message containing the line of the input file and the column name whose input conversion has failed is emitted for each discarded row\&. When it is set to
364 silent, no message is emitted regarding ignored rows\&.
369 Specifies the maximum number of errors tolerated while converting a column\*(Aqs input value to its data type, when
372 ignore\&. If the input causes more errors than the specified value, the
374 command fails, even with
377 ignore\&. This clause must be used with
382 bigint\&. If not specified,
384 allows an unlimited number of errors, meaning
386 will skip all erroneous data\&.
391 Specifies that the file is encoded in the
392 \fIencoding_name\fR\&. If this option is omitted, the current client encoding is used\&. See the Notes below for more details\&.
397 Specifies the amount of messages emitted by a
404 is specified, additional messages are emitted during processing\&.
406 suppresses both verbose and default messages\&.
408 This is currently used in
420 clause has the general form
426 WHERE \fIcondition\fR
434 is any expression that evaluates to a result of type
435 boolean\&. Any row that does not satisfy this condition will not be inserted to the table\&. A row satisfies the condition if it returns true when the actual row values are substituted for any variable references\&.
437 Currently, subqueries are not allowed in
439 expressions, and the evaluation does not see any changes made by the
441 itself (this matters when the expression contains calls to
447 On successful completion, a
449 command returns a command tag of the form
463 is the number of rows copied\&.
469 .nr an-no-space-flag 1
478 will print this command tag only if the command was not
479 COPY \&.\&.\&. TO STDOUT, or the equivalent
482 \ecopy \&.\&.\&. to stdout\&. This is to prevent confusing the command tag with the data that was just printed\&.
488 can be used with plain tables and populated materialized views\&. For example,
490 copies the same rows as
491 SELECT * FROM ONLY \fItable\fR\&. However it doesn\*(Aqt directly support other relation types, such as partitioned tables, inheritance child tables, or views\&. To copy all rows from such relations, use
492 COPY (SELECT * FROM \fItable\fR) TO\&.
495 can be used with plain, foreign, or partitioned tables or with views that have
499 You must have select privilege on the table whose values are read by
500 \fBCOPY TO\fR, and insert privilege on the table into which values are inserted by
501 \fBCOPY FROM\fR\&. It is sufficient to have column privileges on the column(s) listed in the command\&.
503 If row\-level security is enabled for the table, the relevant
505 policies will apply to
507 statements\&. Currently,
509 is not supported for tables with row\-level security\&. Use equivalent
511 statements instead\&.
515 command are read or written directly by the server, not by the client application\&. Therefore, they must reside on or be accessible to the database server machine, not the client\&. They must be accessible to and readable or writable by the
517 user (the user ID the server runs as), not the client\&. Similarly, the command specified with
519 is executed directly by the server, not by the client application, must be executable by the
523 naming a file or command is only allowed to database superusers or users who are granted one of the roles
524 pg_read_server_files,
525 pg_write_server_files, or
526 pg_execute_server_program, since it allows reading or writing any file or running a program that the server has privileges to access\&.
536 \fBCOPY FROM STDIN\fR
538 \fBCOPY TO STDOUT\fR, and then fetches/stores the data in a file accessible to the
540 client\&. Thus, file accessibility and access rights depend on the client rather than the server when
544 It is recommended that the file name used in
546 always be specified as an absolute path\&. This is enforced by the server in the case of
547 \fBCOPY TO\fR, but for
549 you do have the option of reading from a file specified by a relative path\&. The path will be interpreted relative to the working directory of the server process (normally the cluster\*(Aqs data directory), not the client\*(Aqs working directory\&.
551 Executing a command with
553 might be restricted by the operating system\*(Aqs access control mechanisms, such as SELinux\&.
556 will invoke any triggers and check constraints on the destination table\&. However, it will not invoke rules\&.
558 For identity columns, the
560 command will always write the column values provided in the input data, like the
563 OVERRIDING SYSTEM VALUE\&.
566 input and output is affected by
567 \fIDateStyle\fR\&. To ensure portability to other
569 installations that might use non\-default
576 \fBCOPY TO\fR\&. It is also a good idea to avoid dumping data with
579 sql_standard, because negative interval values might be misinterpreted by a server that has a different setting for
580 \fIIntervalStyle\fR\&.
582 Input data is interpreted according to
584 option or the current client encoding, and output data is encoded in
586 or the current client encoding, even if the data does not pass through the client but is read from or written to a file directly by the server\&.
590 command physically inserts input rows into the table as it progresses\&. If the command fails, these rows are left in a deleted state; these rows will not be visible, but still occupy disk space\&. This might amount to considerable wasted disk space if the failure happened well into a large copy operation\&.
592 should be used to recover the wasted space\&.
597 can be used simultaneously on the same column\&. This results in converting quoted null strings to null values and unquoted null strings to empty strings\&.
603 format is used, the data read or written is a text file with one line per table row\&. Columns in a row are separated by the delimiter character\&. The column values themselves are strings generated by the output function, or acceptable to the input function, of each attribute\*(Aqs data type\&. The specified null string is used in place of columns that are null\&.
605 will raise an error if any line of the input file contains more or fewer columns than are expected\&.
607 End of data can be represented by a line containing just backslash\-period (\e\&.)\&. An end\-of\-data marker is not necessary when reading from a file, since the end of file serves perfectly well; in that context this provision exists only for backward compatibility\&. However,
613 operation (that is, reading in\-line
615 data in an SQL script)\&. In that context the rule is needed to be able to end the operation before the end of the script\&.
617 Backslash characters (\e) can be used in the
619 data to quote data characters that might otherwise be taken as row or column delimiters\&. In particular, the following characters
621 be preceded by a backslash if they appear as part of a column value: backslash itself, newline, carriage return, and the current delimiter character\&.
623 The specified null string is sent by
625 without adding any backslashes; conversely,
627 matches the input against the null string before removing backslashes\&. Therefore, a null string such as
629 cannot be confused with the actual data value
631 (which would be represented as
634 The following special backslash sequences are recognized by
671 Carriage return (ASCII 13)
681 Vertical tab (ASCII 11)
686 Backslash followed by one to three octal digits specifies
687 the byte with that numeric code
692 Backslash x followed by one or two hex digits specifies
693 the byte with that numeric code
699 will never emit an octal or hex\-digits backslash sequence, but it does use the other sequences listed above for those control characters\&.
701 Any other backslashed character that is not mentioned in the above table will be taken to represent itself\&. However, beware of adding backslashes unnecessarily, since that might accidentally produce a string matching the end\-of\-data marker (\e\&.) or the null string (\eN
702 by default)\&. These strings will be recognized before any other backslash processing is done\&.
704 It is strongly recommended that applications generating
706 data convert data newlines and carriage returns to the
710 sequences respectively\&. At present it is possible to represent a data carriage return by a backslash and carriage return, and to represent a data newline by a backslash and newline\&. However, these representations might not be accepted in future releases\&. They are also highly vulnerable to corruption if the
712 file is transferred across different machines (for example, from Unix to Windows or vice versa)\&.
714 All backslash sequences are interpreted after encoding conversion\&. The bytes specified with the octal and hex\-digit backslash sequences must form valid characters in the database encoding\&.
717 will terminate each row with a Unix\-style newline (\(lq\en\(rq)\&. Servers running on Microsoft Windows instead output carriage return/newline (\(lq\er\en\(rq), but only for
719 to a server file; for consistency across platforms,
723 regardless of server platform\&.
725 can handle lines ending with newlines, carriage returns, or carriage return/newlines\&. To reduce the risk of error due to un\-backslashed newlines or carriage returns that were meant as data,
727 will complain if the line endings in the input are not all alike\&.
730 This format option is used for importing and exporting the Comma\- Separated Value (CSV) file format used by many other programs, such as spreadsheets\&. Instead of the escaping rules used by
731 PostgreSQL\*(Aqs standard text format, it produces and recognizes the common
733 escaping mechanism\&.
735 The values in each record are separated by the
737 character\&. If the value contains the delimiter character, the
741 string, a carriage return, or line feed character, then the whole value is prefixed and suffixed by the
743 character, and any occurrence within the value of a
747 character is preceded by the escape character\&. You can also use
749 to force quotes when outputting non\-NULL
750 values in specific columns\&.
754 format has no standard way to distinguish a
756 value from an empty string\&.
759 handles this by quoting\&. A
763 parameter string and is not quoted, while a non\-NULL
766 parameter string is quoted\&. For example, with the default settings, a
768 is written as an unquoted empty string, while an empty string data value is written with double quotes ("")\&. Reading values follows similar rules\&. You can use
772 input comparisons for specific columns\&. You can also use
774 to convert quoted null string data values to
777 Because backslash is not a special character in the
779 format, the end\-of\-data marker used in text mode (\e\&.) is not normally treated as special when reading
781 data\&. An exception is that
785 operation (that is, reading in\-line
787 data in an SQL script) at a line containing only
788 \e\&., whether it is text or
796 .nr an-no-space-flag 1
805 versions before v18 always recognized unquoted
807 as an end\-of\-data marker, even when reading from a separate file\&. For compatibility with older versions,
811 when it\*(Aqs alone on a line, even though this is no longer necessary\&.
819 .nr an-no-space-flag 1
829 format, all characters are significant\&. A quoted value surrounded by white space, or any characters other than
830 DELIMITER, will include those characters\&. This can cause errors if you import data from a system that pads
832 lines with white space out to some fixed width\&. If such a situation arises you might need to preprocess the
834 file to remove the trailing white space, before importing the data into
843 .nr an-no-space-flag 1
852 format will both recognize and produce
854 files with quoted values containing embedded carriage returns and line feeds\&. Thus the files are not strictly one line per table row like text\-format files\&.
862 .nr an-no-space-flag 1
870 Many programs produce strange and occasionally perverse
872 files, so the file format is more a convention than a standard\&. Thus you might encounter some files that cannot be imported using this mechanism, and
874 might produce files that other programs cannot process\&.
881 format option causes all data to be stored/read as binary format rather than as text\&. It is somewhat faster than the text and
883 formats, but a binary\-format file is less portable across machine architectures and
885 versions\&. Also, the binary format is very data type specific; for example it will not work to output binary data from a
887 column and read it into an
889 column, even though that would work fine in text format\&.
893 file format consists of a file header, zero or more tuples containing the row data, and a file trailer\&. Headers and data are in network byte order\&.
899 .nr an-no-space-flag 1
908 releases before 7\&.4 used a different binary file format\&.
913 .nr an-no-space-flag 1
920 The file header consists of 15 bytes of fixed fields, followed by a variable\-length header extension area\&. The fixed fields are:
925 PGCOPY\en\e377\er\en\e0
926 \(em note that the zero byte is a required part of the signature\&. (The signature is designed to allow easy identification of files that have been munged by a non\-8\-bit\-clean transfer\&. This signature will be changed by end\-of\-line\-translation filters, dropped zero bytes, dropped high bits, or parity changes\&.)
931 32\-bit integer bit mask to denote important aspects of the file format\&. Bits are numbered from 0 (LSB) to 31 (MSB)\&. Note that this field is stored in network byte order (most significant byte first), as are all the integer fields used in the file format\&. Bits 16\(en31 are reserved to denote critical file format issues; a reader should abort if it finds an unexpected bit set in this range\&. Bits 0\(en15 are reserved to signal backwards\-compatible format issues; a reader should simply ignore any unexpected bits set in this range\&. Currently only one flag bit is defined, and the rest must be zero:
935 If 1, OIDs are included in the data; if 0, not\&. Oid system columns are not supported in
937 anymore, but the format still contains the indicator\&.
941 Header extension area length
943 32\-bit integer, length in bytes of remainder of header, not including self\&. Currently, this is zero, and the first tuple follows immediately\&. Future changes to the format might allow additional data to be present in the header\&. A reader should silently skip over any header extension data it does not know what to do with\&.
946 The header extension area is envisioned to contain a sequence of self\-identifying chunks\&. The flags field is not intended to tell readers what is in the extension area\&. Specific design of header extension contents is left for a later release\&.
948 This design allows for both backwards\-compatible header additions (add header extension chunks, or set low\-order flag bits) and non\-backwards\-compatible changes (set high\-order flag bits to signal such changes, and add supporting data to the extension area if needed)\&.
952 .nr an-no-space-flag 1
959 Each tuple begins with a 16\-bit integer count of the number of fields in the tuple\&. (Presently, all tuples in a table will have the same count, but that might not always be true\&.) Then, repeated for each field in the tuple, there is a 32\-bit length word followed by that many bytes of field data\&. (The length word does not include itself, and can be zero\&.) As a special case, \-1 indicates a NULL field value\&. No value bytes follow in the NULL case\&.
961 There is no alignment padding or any other extra data between fields\&.
963 Presently, all data values in a binary\-format file are assumed to be in binary format (format code one)\&. It is anticipated that a future extension might add a header field that allows per\-column format codes to be specified\&.
965 To determine the appropriate binary format for the actual tuple data you should consult the
967 source, in particular the
971 functions for each column\*(Aqs data type (typically these functions are found in the
972 src/backend/utils/adt/
973 directory of the source distribution)\&.
975 If OIDs are included in the file, the OID field immediately follows the field\-count word\&. It is a normal field except that it\*(Aqs not included in the field\-count\&. Note that oid system columns are not supported in current versions of
980 .nr an-no-space-flag 1
987 The file trailer consists of a 16\-bit integer word containing \-1\&. This is easily distinguished from a tuple\*(Aqs field\-count word\&.
989 A reader should report an error if a field\-count word is neither \-1 nor the expected number of columns\&. This provides an extra check against somehow getting out of sync with the data\&.
993 The following example copies a table to the client using the vertical bar (|) as the field delimiter:
999 COPY country TO STDOUT (DELIMITER \*(Aq|\*(Aq);
1005 To copy data from a file into the
1013 COPY country FROM \*(Aq/usr1/proj/bray/sql/country_data\*(Aq;
1019 To copy into a file just the countries whose names start with \*(AqA\*(Aq:
1025 COPY (SELECT * FROM country WHERE country_name LIKE \*(AqA%\*(Aq) TO \*(Aq/usr1/proj/bray/sql/a_list_countries\&.copy\*(Aq;
1031 To copy into a compressed file, you can pipe the output through an external compression program:
1037 COPY country TO PROGRAM \*(Aqgzip > /usr1/proj/bray/sql/country_data\&.gz\*(Aq;
1043 Here is a sample of data suitable for copying into a table from
1060 Note that the white space on each line is actually a tab character\&.
1062 The following is the same data, output in binary format\&. The data is shown after filtering through the Unix utility
1063 \fBod \-c\fR\&. The table has three columns; the first has type
1064 char(2), the second has type
1065 text, and the third has type
1066 integer\&. All the rows have a null value in the third column\&.
1072 0000000 P G C O P Y \en 377 \er \en \e0 \e0 \e0 \e0 \e0 \e0
1073 0000020 \e0 \e0 \e0 \e0 003 \e0 \e0 \e0 002 A F \e0 \e0 \e0 013 A
1074 0000040 F G H A N I S T A N 377 377 377 377 \e0 003
1075 0000060 \e0 \e0 \e0 002 A L \e0 \e0 \e0 007 A L B A N I
1076 0000100 A 377 377 377 377 \e0 003 \e0 \e0 \e0 002 D Z \e0 \e0 \e0
1077 0000120 007 A L G E R I A 377 377 377 377 \e0 003 \e0 \e0
1078 0000140 \e0 002 Z M \e0 \e0 \e0 006 Z A M B I A 377 377
1079 0000160 377 377 \e0 003 \e0 \e0 \e0 002 Z W \e0 \e0 \e0 \eb Z I
1080 0000200 M B A B W E 377 377 377 377 377 377
1089 statement in the SQL standard\&.
1091 The following syntax was used before
1093 version 9\&.0 and is still supported:
1099 COPY \fItable_name\fR [ ( \fIcolumn_name\fR [, \&.\&.\&.] ) ]
1100 FROM { \*(Aq\fIfilename\fR\*(Aq | STDIN }
1103 [ DELIMITER [ AS ] \*(Aq\fIdelimiter_character\fR\*(Aq ]
1104 [ NULL [ AS ] \*(Aq\fInull_string\fR\*(Aq ]
1106 [ QUOTE [ AS ] \*(Aq\fIquote_character\fR\*(Aq ]
1107 [ ESCAPE [ AS ] \*(Aq\fIescape_character\fR\*(Aq ]
1108 [ FORCE NOT NULL \fIcolumn_name\fR [, \&.\&.\&.] ] ] ]
1110 COPY { \fItable_name\fR [ ( \fIcolumn_name\fR [, \&.\&.\&.] ) ] | ( \fIquery\fR ) }
1111 TO { \*(Aq\fIfilename\fR\*(Aq | STDOUT }
1114 [ DELIMITER [ AS ] \*(Aq\fIdelimiter_character\fR\*(Aq ]
1115 [ NULL [ AS ] \*(Aq\fInull_string\fR\*(Aq ]
1117 [ QUOTE [ AS ] \*(Aq\fIquote_character\fR\*(Aq ]
1118 [ ESCAPE [ AS ] \*(Aq\fIescape_character\fR\*(Aq ]
1119 [ FORCE QUOTE { \fIcolumn_name\fR [, \&.\&.\&.] | * } ] ] ]
1125 Note that in this syntax,
1129 are treated as independent keywords, not as arguments of a
1133 The following syntax was used before
1135 version 7\&.3 and is still supported:
1141 COPY [ BINARY ] \fItable_name\fR
1142 FROM { \*(Aq\fIfilename\fR\*(Aq | STDIN }
1143 [ [USING] DELIMITERS \*(Aq\fIdelimiter_character\fR\*(Aq ]
1144 [ WITH NULL AS \*(Aq\fInull_string\fR\*(Aq ]
1146 COPY [ BINARY ] \fItable_name\fR
1147 TO { \*(Aq\fIfilename\fR\*(Aq | STDOUT }
1148 [ [USING] DELIMITERS \*(Aq\fIdelimiter_character\fR\*(Aq ]
1149 [ WITH NULL AS \*(Aq\fInull_string\fR\*(Aq ]