8. SQL Statements : COPY : Column Formats for COPY : Counted Character Formats
 
Share this page                  
Counted Character Formats
The BYTE VARYING, LONG BYTE, LONG VARCHAR, LONG NVARCHAR, NVARCHAR(n), and VARCHAR formats are "counted" formats: each data file value is preceded by a character count. The character count defines the length of the data value; the actual field length as defined by a fixed-length specifier or a delimiter may be larger. On input (COPY FROM), extra field characters beyond those included by the embedded character count are ignored. On output (COPY INTO), any extra field length after the actual value is filled with padding, as defined by the specific format.
The fixed-length forms are BYTE VARYING(n), NVARCHAR(n), and VARCHAR(n). The variable-length forms are BYTE VARYING(0), LONG BYTE(0), LONG VARCHAR(0), LONG NVARCHAR(0), and VARCHAR(0). An optional delim may follow to specify a delimiter.
Note:  NVARCHAR(0) is not a counted format.
For all fixed-length counted formats: the field length N does not include the preceding length specifier. For example, a VARCHAR(1) field takes 6 bytes. When reading data (COPY FROM), if the character count found in the data is larger than the defined length, a runtime conversion warning is issued and the row is not loaded.
These counted formats are the only ones that can be used with LONG table columns. The two LONG formats can only be used with LONG BYTE or LONG VARCHAR table columns. See COPY Format Details (see COPY Format Details).