Reputation: 114767
I have a h2 database with a schema that is auto generated via JPA/hibernate. Now I want to alter a not-null timestamp
type column on the database to default to the current time.
I actually use a trigger, and that works, but I'd like to know if there's a more elegant way to achieve this, something like (the following snippet doesn't work)
ALTER TABLE my_table ALTER COLUMN my_column SET DEFAULT CURRENT_TIMESTAMP;
I looked at the documentation and tried some variants of the above "pseudo statement" but with now success.
Upvotes: 8
Views: 20370
Reputation: 62841
Looks close, have you tried:
ALTER TABLE <table name> ALTER COLUMN <column name> SET DEFAULT CURRENT_TIMESTAMP
Upvotes: 12