SQL/MX 2.x Reference Manual (G06.24+, H06.03+)
SQL/MX Clauses
HP NonStop SQL/MX Reference Manual—523725-004
7-2
DEFAULT Clause
DEFAULT Clause
Considerations for DEFAULT
Examples of DEFAULT
The DEFAULT option of the CREATE TABLE or ALTER TABLE table-name ADD
COLUMN statement specifies a default value for a column being created. The default
value is used when a row is inserted in the table without a value for the column.
Syntax Description of DEFAULT
DEFAULT literal
is a literal of a data type compatible with the data type of the associated column.
For a character column, literal must be a string literal of no more than 240
characters or the length of the column, whichever is less.
For a numeric column, literal must be a numeric literal that does not exceed
the defined length of the column. The number of digits to the right of the decimal
point must not exceed the scale of the column, and the number of digits to the left
of the decimal point must not exceed the number in the length (or length minus
scale, if you specified scale for the column).
For a datetime column, literal must be a datetime literal with a precision that
matches the precision of the column.
For an INTERVAL column, literal must be an INTERVAL literal that has the
range of INTERVAL fields defined for the column.
DEFAULT NULL
specifies NULL as the default. This default can occur only with a column that
allows null.
DEFAULT CURRENT_DATE
specifies the default value for the column as the value returned by the
CURRENT_DATE function at the time of the operation that assigns a value to the
column. This default can occur only with a column whose data type is DATE.
DEFAULT default | NO DEFAULT
default is:
literal
| NULL
| CURRENT_DATE
| CURRENT_TIME
| CURRENT_TIMESTAMP
| CURRENT_USER
| USER