Download PostgreSQL User`s Guide - BITS
Transcript
Chapter 19. SQL Commands
delimiter
A character that delimits the input or output fields.
null print
A string to represent NULL values. The default is \N (backslash-N), for historical
reasons. You might prefer an empty string, for example.
Note: On a copy in, 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 on copy
out.
Outputs
COPY
The copy completed successfully.
ERROR: reason
The copy failed for the reason stated in the error message.
Description
COPY moves data between Postgres tables and standard file-system files. COPY instructs the
Postgres backend to directly read from or write to a file. The file must be directly visible to the
backend and the name must be specified from the viewpoint of the backend. If stdin or
stdout are specified, data flows through the client frontend to the backend.
Notes
The BINARY keyword will force all data to be stored/read as binary objects rather than as
text. It is somewhat faster than the normal copy command, but is not generally portable, and
the files generated are somewhat larger, although this factor is highly dependent on the data
itself. By default, a text copy uses a tab ("\t") character as a delimiter. The delimiter may also
be changed to any other single character with the keyword phrase USING DELIMITERS.
Characters in data fields which happen to match the delimiter character will be quoted.
You must have select access on any table whose values are read by COPY, and either insert or
update access to a table into which values are being inserted by COPY. The backend also
needs appropriate Unix permissions for any file read or written by COPY.
The keyword phrase USING DELIMITERS specifies a single character to be used for all
delimiters between columns. If multiple characters are specified in the delimiter string, only the
first character is used.
Tip: Do not confuse COPY with the psql instruction \copy.
129