SQL$HELP72.HLB  —  ALTER  TABLE  Arguments  DEFAULT value-expr
    Provides a default value for a column if the row that is inserted
    does not include a value for that column.

    You can use any value expression including subqueries,
    conditional, character, date/time, and numeric expressions as
    default values. See Value Expressions for more information about
    value expressions.

    For more information about NULL, see the NULL_Keyword HELP topic.

    You can add a default value to an existing column or alter
    the existing default value of a column by altering the table.
    However, doing so has no effect on the values stored in existing
    rows.

    The value expressions described in Value Expressions include
    DBKEY and aggregate functions. However, the DEFAULT clause is
    not a valid location for referencing a DBKEY or an aggregate
    function. If you attempt to reference either, you receive a
    compile-time error.

    If you do not specify a default value, a column inherits the
    default value from the domain. If you do not specify a default
    value for either the column or domain, SQL assigns NULL as the
    default value.

    If you specify a default value for either the column or domain
    when a column is added, SQL propagates the default value from the
    column or domain to all previously stored rows. Therefore, when
    you add a column to a table and specify a default value for the
    column, SQL stores the default value in the newly added column
    of all the previously stored rows. Likewise, if the newly added
    column is based upon a domain that specifies a default value, SQL
    stores the default value in the column of all previously stored
    rows.

    Because SQL updates data when you add a column with a default
    value other than NULL, the ALTER TABLE statement can take some
    time to complete when the table contains many rows. (If you
    specify a default value of NULL, SQL does not modify the data
    because SQL automatically returns a null value for columns that
    have no actual value stored in them.) If you want to add more
    than one column with default values, add them in a single ALTER
    TABLE statement. When you do so, SQL scans the table data once
    instead of many times.

    Because data is added to the rows, adding a column with a default
    value may result in fragmented records. For information about
    locating and correcting record fragmentation, see the Oracle Rdb7
    Guide to Database Performance and Tuning.
Close Help