Specifying a built-in column's data type and default options

These steps are part of the larger task of adding a column. When you complete the steps for specifying a built-in column, return to Adding a column.



To specify a built-in column's data type and default options:

  1. On the Built-in Type page, use the Data type box to specify the data type of the column.
  2. Optional: If you specified a data type of CHAR, VARCHAR, GRAPHIC, VARGRAPHIC, CLOB, BLOB, or DBCLOB, use the Length field to specify the length (byte count) of the column. The default length is 1 character.
  3. Optional: If you specified a data type of CLOB, BLOB, or DBCLOB, use the LOB unit box to specify the units in which to measure the length of the CLOB, BLOB, or DBCLOB column. The LOB units multiplied by the value that you specify in the Length field sets the maximum length for the column.

    For example, a CLOB column with a LOB unit of K Bytes, has a maximum column length of 1024 times the value specified in the Length field.

  4. Optional: If you specified a data type of DECIMAL, use the Precision and Scale fields to specify the precision (total number of digits) for the column and the scale (number of digits to the right of the decimal) for the column. The default precision is 5 and the default scale is 0.
  5. Optional: If you specified a data type of CHAR, VARCHAR, or CLOB, use the Data sub-type box to specify a subtype for this column. The sub-type can be:
    SBCS
    Column holds single-byte data.
    MIXED
    Column holds mixed data. MIXED can be specified only if the DB2 installation allows mixed data.
    BIT
    Column holds BIT data. Do not specify BIT for a CLOB column.
  6. If you do not want the column to contain null values, clear the Nullable check box. The default is nullable.

    DB2 implicitly defines ROWID columns to be NOT NULL.

    If you're adding this column when you are altering a table and you clear this check box to make this column non-nullable, you must also specify a non-nullable default for this column in the next step unless the column has the ROWID data type.

  7. Optional: To specify that a default value be assigned to the column when no value is specified on an INSERT or LOAD, select the Default check box and specify one of the following choices. The available choices shown in the box depend on the data type that you selected.

    constant value
    The column's default value is a constant. To specify the constant, type a value in the Constant value field. The value of the constant must be a valid value for the data type.

    If you do not type a value in the Constant value field, the default value depends on the data type of the column.

    If the column data type is CLOB, BLOB, or DBCLOB, do not specify a value in the Constant value field. The default value will be a zero-length string.

    USER
    The column's default value is the execution-time value of the USER special register. This choice is available only for a character string column with a length attribute of at least 8 bytes.

    If you're adding this column when you are altering a table, the value for existing rows is that of the USER special register at the time that the table is altered.

    CURRENT SQLID
    The column's default value is the SQL authorization ID (SQLID) of the process. The SQLID is the DB2 subsystem user identifier for the current connection. This value can be specified only for a character string column with a length attribute of at least 8 bytes.

    If you're adding this column when you are altering a table, the value for existing rows is that of the SQLID special register at the time that the table is altered.

    NULL
    The column's default value is the null value. NULL is available only if the Nullable check box is selected.

    Do not specify NULL for a CLOB, BLOB, or DBCLOB column.

  8. You cannot specify Default for a ROWID column.

  9. Optional: To specify how values are generated for a ROWID column, select either the Always or By default radio button.
  10. If you do not want to define a field procedure or comment for this column, click Apply to add the new column. Otherwise, return to the main task.