Fujitsu J2X0-1634-01EN Computer Accessories User Manual


 
3.1.2 Using default values in data to be added
Default values, also referred to as fixed values, can be defined for each column in a table when the table is defined.
The default values can be used by the INSERT statement to add data. If no value is specified for a column for which
no default value is defined, a null value is added to the column. However, processing ends in an error if the column
has a NOT NULL constraint.
Setting a default value for a column in which data is to be added
To set a default value for a column in which data is to be added, specify the keyword "DEFAULT" in the insert value list
of the INSERT statement. In this case, the name of the column for which the default value is to be set cannot be
omitted from the insert column list. The following is an example in which default values for two columns are set:
Example 1:
In this example, a row of data is added to the ORDER table. The data to be added is as follows: "78"
for CUSTOMER and "400" for PRODNO. PRICE and ORDERQTY are specified with the default values
defined for the columns.
[Figure: Adding data using default values]
To set a default value for a column in which data is to be added, instead of specifying the keyword "DEFAULT", omit
the value from the insert value list. In this case, also omit the name of the column for which the default value is to be
set from the insert column list. The following is an example in which the insert value list and the insert column list for
the INSERT statement in Example 1 are omitted:
Example 2:
In this example, the value to be added and the column to which it is to be added are omitted. The data
added is the same as in Example 1.
23