COPY LOCAL rejection and exception files
Invoking COPY LOCAL (or COPY LOCAL FROM STDIN) does not automatically create rejected data and exceptions files. This behavior differs from using COPY, which saves both files automatically, regardless of whether you use the optional REJECTED DATA
and EXCEPTIONS
parameters to specify either file explicitly.
Use the REJECTED DATA
and EXCEPTIONS
parameters with COPY LOCAL and COPY LOCAL FROM STDIN to save the corresponding output files on the client. If you do not use these options, rejected data parsing events (and the exceptions that describe them) are not retained, even if they occur.
You can load multiple input files using COPY LOCAL (or COPY LOCAL FROM STDIN). If you also use the REJECTED DATA
and EXCEPTIONS
options, the statement writes rejected rows and exceptions and to separate files. The respective files contain all rejected rows and corresponding exceptions, respectively, regardless of how many input files were loaded.
If COPY LOCAL does not reject any rows, it does not create either file.
Note
Because COPY LOCAL (and COPY LOCAL FROM STDIN) must write any rejected rows and exceptions to the client, you cannot use the[ON nodename ]
clause with either the rejected data
or exceptions
options.
Specifying rejected data and exceptions files
To save any rejected data and their exceptions to files:
-
In the COPY LOCAL (and COPY LOCAL FROM STDIN) statement, use the
REJECTED DATA 'path'
and theEXCEPTIONS 'path'
parameters, respectively. -
Specify two different file names for the two options. You cannot use one file for both the
REJECTED DATA
and theEXCEPTIONS
. -
When you invoke COPY LOCAL or COPY LOCAL FROM STDIN, the files you specify need not pre-exist. If they do, COPY LOCAL must be able to overwrite them.
You can specify the path and file names with vsql variables:
\set rejected ../except_reject/copyLocal.rejected
\set exceptions ../except_reject/copyLocal.exceptions
Note
UsingCOPY LOCAL
does not support storing rejected data in a table, as you can when using the COPY
statement.
When you use the COPY LOCAL or COPY LOCAL FROM STDIN statement, specify the variable names for the files with their corresponding parameters:
=> COPY large_tbl FROM LOCAL rejected data :rejected exceptions :exceptions;
=> COPY large_tbl FROM LOCAL STDIN rejected data :rejected exceptions :exceptions;