Timestamp columns may have
DEFAULT NOW() ON UPDATE NOW() which is awesome to keep track of when the row was updated.
I want to have similar functionality with user id, such that when an
update statement is executed with
last_user_id = 42 then the value 42 is stored. But when the
update statement is missing the assignment of
last_user_id it is automatically reset to
NULL, to indicate that the last modification to the row has happened in a context without any user.
Is it possible to use
DEFAULT ON UPDATE for non-timestamp columns? If not, is it possible to achieve this behavior with triggers?