Why Generated Columns doesn’t support NOW() function?
I’ve got error:
Update column failed. Expression of generated column ‘currentWeekDay’ contains a disallowed function.
I want to create simple column:
One of the rules applied to generated columns is that the expression must use deterministic functions.
What is a deterministic function? Here’s a definition straight from the underlying database docs:
A function is deterministic if, given the same data in tables, multiple invocations produce the same result, independently of the connected user. Examples of functions that are nondeterministic and fail this definition:
It is still possible to create a generated column as you describe it, however, instead of
CURDATE() use the
created or the
update columns, for example:
WEEKDAY( created )