Search code examples
hsqldbrdbms

HSQLDB - Can't update identity column


I have a column like this:

MYID INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY

I know that when doing an INSERT it's possible to override the generated value. However once the row has been created I can't find a way to use an UPDATE to change the value.
Is there a way to do it?


Solution

  • GENERATED ALWAYS means what is says. You cannot override the values. If you want the system to simply ignore the values you provide, you can use OVERRIDING USER VALUES in the INSERT statement. Otherwise you cannot supply values for the GENERATED column. Values for columns defined as GENERATED BY DEFAULT can be overridden by the user.