Let's say we have a database table named Users
and a column named CreatedAt
. When a new user is inserted into Users
, the value of column CreatedAt
is set to the current timestamp.
Now let's say the value of CreatedAt
should never be allowed to change. Afterall, it's the date the user joined, it's basically their anniversary date.
Does H2 Database support the ability to prevent a column from being modified? In this case, we want to prevent any modification of the CreatedAt
column.
Seems MySQL supports this feature via Triggers, for example:
CREATE TRIGGER my_trig BEFORE UPDATE ON Users
FOR EACH ROW BEGIN
SET NEW.CreatedAt = OLD.CreatedAt
END
Thanks for your help.