Saving Load Exceptions (EXCEPTIONS)
COPY exceptions consist of informational messages describing why a row of data could not be parsed. The optional EXCEPTIONS
parameter lets you specify a file to which COPY
writes exceptions. If you omit this parameter, COPY
saves exception files to the following default location:
catalog‑dir/CopyErrorLogs/tablename-sourcefilename-copy-from-exceptions
catalog-dir | Database catalog files directory |
table-sourcefile | Names of the target table and source data file |
-copy-from-exceptions | File suffix appended to table and source file name |
Using REJECTED DATA AS TABLE r_table
is mutually exclusive with using the EXCEPTIONS filename
parameter. The rejected data table includes a column with the exceptions messages. COPY
does not permit both parameters. Trying to do so results in this error:
ERROR 0: Cannot specify both an exceptions file and a rejected table in the same statement
The optional EXCEPTIONS
parameter lets you specify a file of your choice to which COPY
writes load exceptions. The EXCEPTIONS
file indicates the input line number and the reason for each data record exception in this format:
COPY: Input record
numberin pathofinputfile has been rejected (
reason). Please see
pathtorejectfile, record
recordnumfor the rejected record
.
If copying from STDIN
, the filename-of-source is STDIN
.
You can use specific rejected data and exceptions files with one or more of the files you are loading. Separate consecutive rejected data and exception file names with a comma (,) in the COPY
statement.
You must specify a filename in the path to load multiple input files. Keep in mind that long table names combined with long data file names can exceed the operating system's maximum length (typically 255 characters). To work around file names exceeding the maximum length, use a path for the exceptions file that differs from the default path; for example, \tmp\<shorter-file-name>
.
For all data loads (except for COPY LOCAL
), COPY
behaves as follows:
No exceptions file specified |
|
Exceptions file specified |
|