Rules for Using the DEFAULT Function With Update
The following rules apply to using the DEFAULT function with an UPDATE statement:
The DEFAULT function takes a single argument that identifies a relation column by
name. The function evaluates to a value equal to the current default value for the
column. For cases where the default value of the column is specified as a current
built‑in system function, the DEFAULT function evaluates to the current value of system
variables at the time the request is executed.
The resulting data type of the DEFAULT function is the data type of the constant or
built-in function specified as the default unless the default is NULL. If the default
is NULL, the resulting date type of the DEFAULT function is the same as the data type
of the column or expression for which the default is being requested.
The DEFAULT function has two forms. It can be specified as DEFAULT
or DEFAULT (
column_name)
. When no column name is specified, the system derives the column based on context.
If the column context cannot be derived, the request aborts and an error is returned
to the requestor.
You can specify a DEFAULT function without a column name argument as the expression
in the SET clause. The column name for the DEFAULT function is the column specified
as the column_name. The DEFAULT function evaluates to the default value of the column specified as column_name.
You cannot specify a DEFAULT function without a column name argument as part of the
expression. It must be specified by itself. This rule is defined by the ANSI SQL:2011
specification.
You can specify a DEFAULT function with a column name argument in the source expression.
The DEFAULT function evaluates to the default value of the column specified as the
input argument to the DEFAULT function.
For example, DEFAULT(col2) evaluates to the default value of col2. This is a Teradata
extension to the ANSI SQL:2011 specification.
You can specify a DEFAULT function with a column name argument anywhere in an update
expression. This is a Teradata extension to the ANSI SQL:2011 specification.
When no explicit default value has been defined for a column, the DEFAULT function
evaluates to null when that column is specified as its argument.
See SQL Functions, Operators, Expressions, and Predicates for more information about the DEFAULT function.