Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Default values for table columns

The rules that apply to the default value for a column that you can specify with the DEFAULT clause of the CREATE TABLE or ALTER TABLE statement are more strict than those for entering values in table columns. The rules also apply for the definition of local variables (in routines). They are contained in the table below:

SQL data type of the
column

Possible SQL default value

CHAR(length)
VARCHAR(max)

  • Alphanumeric literal with length <= length or max

  • Special literal ([CURRENT_ ]USER and
    SYSTEM_USER only (only recommended for length or
    max <= 128))

  • NULL

NCHAR(cu_length)
NVARCHAR(cu_max

  • National literal with length >= cu_length or cu_max

  • NULL

REF(table)

  • As for CHAR(237)

DECIMAL(precision,scale)
NUMERIC(precision,scale)
INTEGER
SMALLINT

  • Fixed-point or floating-point number belonging to the
    range of values for the column

  • NULL

REAL, DOUBLE PRECISION
FLOAT(precision)

  • Numeric literal
    (the number is rounded off if necessary)

  • NULL

DATE

  • Literal of the type DATE

  • CURRENT_DATE

  • NULL

TIME(3)

  • Literal of the type TIME(3)

  • CURRENT_TIME

  • NULL

TIMESTAMP(3)

  • Literal of the type TIMESTAMP(3)

  • CURRENT_TIMESTAMP

  • NULL

Table 12: Default values for table columns