Data Types Explicit Default Handling
The default value specified in a DEFAULT
clause can be a literal constant or an expression. With one exception, enclose expression default values within parentheses to distinguish them from literal constant default values. Examples:
The exception is that, for TIMESTAMP
and DATETIME
columns, you can specify the CURRENT_TIMESTAMP
function as the default, without enclosing parentheses. SeeSection 13.2.5, “Automatic Initialization and Updating for TIMESTAMP and DATETIME”.
The BLOB
, TEXT
, GEOMETRY
, and JSON
data types can be assigned a default value only if the value is written as an expression, even if the expression value is a literal:
This is permitted (literal default specified as expression):
This produces an error (literal default not specified as expression):
Last updated