Formatted Copying
Formatted copying allows the type, number, and order of columns in the data file to differ from the table. By specifying a list of columns and their types in the COPY statement, you instruct Vector to perform a formatted copy. The COPY statement list specifies the order and type of columns in the data file. The column names in the list are used to match the data in the file with the corresponding columns in the table.
For human readable text data files, the COPY list formats will almost always be a character type: char, c, text, or less commonly varchar or byte. The COPY statement converts (character) file data into table data types for COPY FROM, or the reverse for COPY INTO. The COPY list may contain other types as well, such as integer or decimal, but these are binary types for special programming situations; they are not human readable types. COPY also supports a “dummy” type, used to skip input data (FROM) or insert fixed output text (INTO).
If some table columns are not listed in the COPY list for a COPY FROM, those columns are defaulted. (If they are defined in the table as NOT DEFAULT, an error occurs.) If some table columns are not listed for a COPY INTO, those table columns simply do not appear in the output data file.
The order of columns in the table need not match the order in the data file. Remember that the order of columns in the COPY list reflects the order in the data file, not the order in the table. Additionally, a table column may be named more than once. (For COPY FROM, if a column is named multiple times, the last occurrence in the COPY list is the one that is stored into the table. Earlier occurrences undergo format conversion, but the result is discarded.)
The values in the data file can be fixed-length or variable-length. Values can optionally be ended with a
delimiter (see
Delimiters in the Data File); the delimiter is specified in the COPY list. COPY can also process a special case of delimited values, the comma-separated values (CSV) delimiting form.
Note: If II_DECIMAL is set to comma, you must follow any comma required in SQL syntax (such as a fixed-length COPY type) by a space. For example:
COPY TABLE t (col1=c20, col2=c30, d0=nl) INTO ‘t.out’: