COPY Parameters
Parameters and their descriptions are divided into the following sections:
Target Options
The following parameters apply to the target tables and their columns:
[database.]schema |
Specifies a schema, by default myschema.thisDbObject If you specify a database, it must be the current database.
|
target-table |
The target columnar or flexible table for loading new data. Vertica loads the data into all projections that include columns from the schema table. |
column-as-expression |
Specifies the expression used to compute values for the target column. For example: => COPY t(year AS TO_CHAR(k, 'YYYY')) FROM 'myfile.dat' Use this option to transform data when it is loaded into the target database. For details, see Transforming Data During Loads. |
column |
Restricts the load to one or more specified columns in the table. If you omit specifying columns, Table columns that you omit from the column list are assigned their DEFAULT or SET USING values, if any; otherwise, If you leave the The data file must contain the same number of columns as the => COPY T1 (C1, C6, C9); |
COLUMN OPTION |
Specifies load metadata for one or more columns declared in the table column list. For example, you can specify that a column has its own |
Column Options
Depending on how they are specified, the following COPY options can qualify specific columns or all columns. Some parser-specific options can also apply to either specific columns or all columns. See Global and Column-Specific Options For details about these two modes.
ENFORCELENGTH |
If specified, By default, If a collection does not fit with all of its elements, |
FILLER datatype |
Specifies not to copy the data of an input column, one of the following:
For details, see Transforming Data During Loads. |
FORMAT 'format' |
Specifies the input formats to use when loading date/time and binary columns, where format can be one of the following: These are the valid input formats when loading binary columns:
See Loading Binary (Native) Data to learn more about these formats. When loading date/time columns, using FORMAT significantly improves load performance. See the following topics for additional information: If you specify invalid format strings, the |
NULL [AS] |
The string representing a null value. The default is an empty string ( |
Input Options
The following options are available for specifying source data:
LOCAL |
Specifies to load a data file on a client system, rather than on a cluster host. Restrictions: Invalid for CREATE EXTERNAL TABLE AS COPY |
STDIN |
Reads from the client a standard input instead of a file. User must have INSERT privileges on the table and USAGE privileges on its schema. Restrictions: Invalid for CREATE EXTERNAL TABLE AS COPY |
path-to-data
|
Specifies the absolute path of the file (or files) containing the data, which can be from multiple input sources.
path‑to‑data can optionally contain wildcards to match more than one file. The file or files must be accessible to the local client or the host on which the You can use variables to construct the pathname as described in Using Load Scripts. If path‑to‑data resolves to a storage location on a local file system, and the user invoking
Further, if a user has privileges but is not a superuser, and invokes |
ON nodename |
Specifies the node on which the data to copy resides and the node that should parse the load file. If you omit nodename, the location of the input file defaults to the initiator node. Use nodename to copy and parse a load file from a node other than the nodename is invalid with |
ON (nodeset) |
Specifies a set of nodes on which to perform the load. The same data must be available for load on all named nodes. nodeset is a comma-separated list of node names in parentheses. For example: => COPY t FROM 'file1.txt' ON (v_vmart_node0001, v_vmart_node0002); Vertica apportions the load among all of the specified nodes. If you also specify If the data is available on all nodes, you usually use |
ON ANY NODE |
Specifies that the source file to load is available on all nodes, so The file must be the same on all nodes. If the file differs on two nodes, an incorrect or incomplete result is returned, with no error or warning. Vertica attempts to apportion the load among several nodes if the file is large enough to benefit from apportioning. It chooses a single node if You can use a wildcard or glob (such as
|
input‑format |
Specifies the input format, one of the following:
Input files can be of any format. If you use wildcards, all qualifying input files must be in the same format. To load different file formats, specify the format types specifically. The following requirements and restrictions apply:
|
VERTICA | See COPY FROM VERTICA. |
[WITH] UDL‑clause[…] |
Specifies one or more user-defined load functions—one source, and optionally one or more filters and one parser, as follows: SOURCE source( [arg=value[,...] ] [ FILTER filter( [arg=value[,...] ] ) ]... [ PARSER parser( [arg=value[,...] ] ) ] To use a flex table parser for column tables, use the |
Handling Options
The following parameters provide various options for controlling how COPY handles different contingencies:
ABORT ON ERROR |
Specifies that |
COLSIZES (integer[,…]) |
Specifies column widths when loading fixed-width data. |
ERROR TOLERANCE |
Specifies that Using this parameter disables apportioned load. Restrictions: Invalid for ORC or Parquet data |
EXCEPTIONS |
Specifies the file name or absolute path of the file in which to write exceptions, as follows: EXCEPTIONS 'path' [ ON nodename[,…]] Exceptions describe why each rejected row was rejected. Each exception describes the corresponding record in the file specified by the Files are written on the node or nodes executing the load. If the file already exists, it is overwritten. To collect all exceptions in one place, use the
The If you use this parameter with EXCEPTIONS '/home/ex01.txt' on v_db_node0001,'/home/ex02.txt' on v_db_node0002,'/home/ex03.txt' on v_db_node0003 If path resolves to a storage location, the following privileges apply to non-superusers:
|
REJECTED DATA |
Specifies where to write each row that failed to load. If this parameter is specified, records that failed due to parsing errors are always written. Records that failed due to an error during a transformation are written only if configuration parameter CopyFaultTolerantExpressions is set. The syntax for this parameter is: REJECTED DATA { 'path' [ ON nodename ] [,...] | AS TABLE reject-table } Vertica can write rejected data to the specified path or to a table:
For details about both options, see Handling Messy Data. |
REJECTMAX integer |
The maximum number of logical records that can be rejected before a load fails. For details, see Handling Messy Data.
|
SKIP integer |
The number of records to skip in a load file. For example, you can use the Restrictions: Invalid for ORC or Parquet data |
STREAM NAME |
Supplies a A valid stream name can contain any combination of alphanumeric or special characters up to 128 bytes in length. By default, Vertica names streams by table and file name. For example, if you are loading two files ( For example: => COPY mytable FROM myfile DELIMITER '|' STREAM NAME 'My stream name'; |
WITH parser |
Specifies the parser to use when bulk loading columnar tables, one of the following:
By default, To use a flex table parser for column tables, use the For parser support for complex data types, see the documentation of the specific type. You do not specify the DELIMITER parser directly; absence of a specific parser indicates the default. For details, see Parsers for Various Data Formats in Getting Data into Vertica. The following restrictions apply:
|
NO COMMIT |
Prevents the For details, see Using Transactions to Stage a Load. Restrictions: Invalid for ORC or Parquet data , ignored by CREATE EXTERNAL TABLE AS COPY |
Parser-Specific Options
The following parameters apply only when using specific parsers.
DELIMITED Parser
DELIMITER |
Indicates the single ASCII character used to separate columns within each record of a file. You can use any ASCII value in the range E'\000' to E'\177', inclusive. You cannot use the same character for both the DELIMITER and NULL parameters. For more information, see Loading Delimited Data. Default: Vertical bar ('|'). |
ENCLOSED [BY] |
Sets the quote character within which to enclose data, allowing delimiter characters to be embedded in string values. You can choose any ASCII value in the range E'\001' to E'\177' inclusive (any ASCII character except NULL: E'\000'). By default, ENCLOSED BY has no value, meaning data is not enclosed by any sort of quote character. |
ESCAPE [AS] |
Sets the escape character. Once set, the character following the escape character is interpreted literally, rather than as a special character. You can define an escape character using any ASCII value in the range E'\001' to E'\177', inclusive (any ASCII character except NULL: E'\000'). The COPY statement does not interpret the data it reads in as String Literals. It also does not follow the same escape rules as other SQL statements (including the COPY parameters). When reading data, COPY interprets only the characters defined by these options as special values:
Default: Backslash ('\'). |
NO ESCAPE |
Eliminates escape-character handling. Use this option if you do not need any escape character and you want to prevent characters in your data from being interpreted as escape sequences. |
RECORD TERMINATOR |
Specifies the literal character string indicating the end of a data file record. For more information about using this parameter, see Loading Delimited Data. |
TRAILING NULLCOLS |
Specifies that if Vertica encounters a record with insufficient data to match the columns in the table column list, COPY inserts the missing columns with NULL values. For other information and examples, see Loading Fixed-Width Format Data |
COLLECTIONDELIMITER |
For columns of collection types, indicates the single ASCII character used to separate elements within each collection. You can use any ASCII value in the range E'\000' to E'\177', inclusive. No COLLECTION option may have the same value as any other COLLECTION option. For more information, see Loading Delimited Data. Default: Comma (','). |
COLLECTIONOPEN COLLECTIONCLOSE |
For columns of collection types, these options indicate the characters that mark the beginning and end of the collection. It is an error to use these characters elsewhere within the list of elements without escaping them. No COLLECTION option may have the same value as any other COLLECTION option. Default: Square brackets ('[' and ']'). |
COLLECTIONNULLELEMENT |
The string representing a null element value in a collection. You can specify a null value as any ASCII value in the range E'\001' to E'\177' inclusive (any ASCII value except NULL: E'\000'). No COLLECTION option may have the same value as any other COLLECTION option. For more information, see Loading Delimited Data. Default: 'null' |
COLLECTIONENCLOSE |
For columns of collection types, sets the quote character within which to enclose individual elements, allowing delimiter characters to be embedded in string values. You can choose any ASCII value in the range E'\001' to E'\177' inclusive (any ASCII character except NULL: E'\000'). No COLLECTION option may have the same value as any other COLLECTION option. Default: double quote ('"') |
FIXEDWIDTH Parser
SKIP BYTES integer |
The total number of bytes in a record to skip. |
TRIM |
Trims the number of bytes you specify from a column. This option is only available when loading fixed-width data. You can set TRIM at the table level for a column, or as part of the COLUMN OPTION parameter. |