Skip to main content
The DEFAULT value constraint specifies a value to write into the constrained column if one is not defined in an INSERT statement. The value may be either a hard-coded literal or an expression that is evaluated at the time the row is created.

Details

  • The data type of the DEFAULT value must be the same as the data type of the column.
  • The DEFAULT value constraint only applies if the column does not have a value specified in the INSERT statement. You can still insert a NULL into an optional (nullable) column by explicitly inserting NULL. For example, INSERT INTO foo VALUES (1, NULL);.

Syntax

default_value_column_level syntax diagram You can only apply the DEFAULT value constraint to individual columns.
You can also add the DEFAULT value constraint to an existing table through ALTER COLUMN.

Example

If the DEFAULT value constraint is not specified and an explicit value is not given, a value of NULL is assigned to the column.

See also