ID EN
Miscellaneous Functions

DEFAULT(col_name)

MySQL 8.4

Returns the default value for a table column. An error results if the column has no default value.

Syntax

MYSQL
UPDATE t SET i = DEFAULT(i)+1 WHERE id < 100;

Examples

Example

The use of DEFAULT(col_name) to specify the default value for a named column is permitted only for columns that have a literal default value, not for columns that have an expression default value.

MYSQL
UPDATE t SET i = DEFAULT(i)+1 WHERE id < 100;