\copy Parameters
- FROM
You can copy data from either local source files or
STDINand load it into tables or columns in tables.- TO
You can copy data to either local output files or
STDOUT, using a query, a table, or table columns as the source. The default output format istext.- FORMAT
The format of the input or output can be
text,csv, orbinary.- DELIMITER
A single one-byte character that represents the field delimiter, such as a pipe (|) or a comma (,).
- NULL
The string that represents
NULLvalues, such as''(empty string).- HEADER
Whether the source (or destination file) contains a header row:
'true'or'false'. If you are copying from a file and this option is set to'true', the first line in the file will be skipped. This option applies tocsvformat only. If you specify the optionheaderby itself, this also means'true'.- QUOTE
A single one-byte character that is used when a data value is quoted. The default value is
". This option applies only tocsvformat.- ESCAPE
A single one-byte character that should appear before a data character that matches the
QUOTEvalue. The default is the same as theQUOTEvalue (so that the quote character is doubled if it appears in the data). This option applies only tocsvformat.- FORCE_QUOTE
Adds quotes to output column values that are not
NULL.NULLvalues are never quoted. You can quote specific columns in the table or all columns (*). This option applies only to\copy tocommands that usecsvformat.- FORCE_NULL (column_list), FORCE_NOT_NULL (column_list)
Either match or do not match the values in the specified list of columns against the null string. Both options apply only to
\copy fromcommands that usecsvformat.FORCE_NOT_NULL: If a match is found, do not set the value toNULL. If the null string is empty (the default), empty values will be read and inserted as zero-length strings, not asNULLvalues, whether or not they are quoted.FORCE_NULL: If a match is found, set the value toNULL. If the null string is empty, a quoted empty string is converted toNULL.- ENCODING
Typically set to
'utf8'or'latin9'. For\copy fromcommands, see also the discussion of encodings in Creating Databases.
Parent topic:ybsql \copy Command