Syntax Rules for Column Descriptions
<load_column_spec_mlt> ::= <load_column_spec > <load_column_spec_mlt>
Use this syntax rule in a command for loading application data to describe the data records you want to load from a data stream and their assignment to the columns of the target table.
Table definition:
CREATE TABLE sqltravel00.customer (cno FIXED(4,0), name CHAR(10) NOT NULL, zip CHAR(5), address CHAR(25), PRIMARY KEY (cno))
Load command:
DATALOAD TABLE customer
cno 01-04
name 06-16
zip 17-22
address 23-48
INFILE 'customer.data' FORMATTED
Data must exist in the data stream for every column that you specify in the load command.
If you do not specify columns in the target table in the command, the entire column is populated with the default value defined for this column during the load operation. The NULL value is loaded if no specific default value is defined for the column.
DATALOAD TABLE customer
cno 01-04
name 06-16
INFILE 'customer.data' FORMATTED
zip and address are filled with the default value when the data is loaded
Key columns and mandatory columns (columns that are defined as NOT NULL without a default value) must be specified in the load command. Otherwise, the processing terminates with an SQL error.
DATALOAD TABLE customer
name 06-16
zip 17-22
address 23-48
INFILE 'customer.data' FORMATTED
The command is terminated with an SQL error, as the column cno is missing.
If you do not specify any columns for the target table in the load command, the table is loaded as if all columns in the target table were specified in the command. If this is the case, data must exist in the data stream for all of the columns in the target table.
DATALOAD TABLE customer
INFILE 'customer.data' FORMATTED
Data must exist in the data stream for all of the columns in the target table.