LOAD TABLE supports loading default values [CR 396843]

Sybase IQ 12.7 ESD #4 supports loading a default value into a column as specified in the LOAD TABLE statement. You can now load a default value into a column, even if the column does not have a default value defined in the table schema. This feature carries the performance benefits of the LOAD TABLE statement and provides the user with more flexibility at load time.

The LOAD TABLE syntax includes a new DEFAULT clause in the column specification.

Syntax

LOADINTO ] TABLEowner.]table-name
... ( load-specification [, …] )
... FROM { 'filename-string' | filename-variable } [, …]
... [ CHECK CONSTRAINTSON | OFF } ]
... [ DEFAULTSON | OFF } ]
... QUOTES OFF
... ESCAPES OFF
... [ FORMATascii | binary } ]
... [ DELIMITED BY 'string' ]
... [ STRIPON | OFF } ]
.
.
.

Parameters

load-specification:{ column-namecolumn-spec ] | FILLERfiller-type ) } column-spec:{ ASCIIinput-width ) | BINARYWITH NULL BYTE ] | PREFIX1 | 2 | 4 } | 'delimiter-string' | DATEinput-date-format ) | DATETIMEinput-datetime-format ) } [ NULL ( { BLANKS | ZEROS | 'literal',  …} ) ] | ENCRYPTED (data-typekey-string’ [, ‘algorithm-string’ ] ) | DEFAULT default-value

Examples

The following LOAD TABLE statements are now supported with the DEFAULT load clause:

LOAD TABLE t1 (c1 DEFAULT ‘12345 ’, c2, c3, filler(1))
FROM ‘LoadConst04.dat’
DEFAULTS ON
STRIP OFF
QUOTES OFF
ESCAPES OFF
DELIMITED BY ‘,’;
LOAD TABLE t1 (c1, c2, c3 DEFAULT ‘10’)
FROM ‘bcp_file.bcp’
DEFAULTS ON
FORMAT BCP
QUOTES OFF
ESCAPES OFF;

Usage

DEFAULT Use the DEFAULT value specifier in the column specification to specify a load default column value. The LOAD TABLE DEFAULTS clause must be set to ON in order to use the default value specified in the LOAD TABLE statement. If the DEFAULTS clause is OFF, the specified load default value is not used and a NULL value is inserted into the column instead.

The LOAD TABLE DEFAULT value specification must contain at least one column that needs to be loaded from the file specified in the LOAD TABLE command. Otherwise, an error is reported and the load is not performed.

The specified load default value must conform to the supported default values for columns and default value restrictions as described in the section “Using column defaults” in Chapter 9, “Ensuring Data Integrity” of the Sybase IQ System Administration Guide. The LOAD TABLE DEFAULT value specification does not support AUTOINCREMENT, IDENTITY, or GLOBAL AUTOINCREMENT as a load default value.

The LOAD TABLE DEFAULT value specification must be of the same character set as that of the database.

Encryption of the default value is not supported for the load default values specified in the LOAD TABLE DEFAULT value specification.

A constraint violation caused by evaluation of the specified load default value is counted for each row that is inserted in the table.

Error messages

Sybase IQ no longer returns an error message when FORMAT BCP is specified as a LOAD TABLE clause.