Search code examples
sequencehsqldb

How to create a new sequence starting with the value of another sequence in hsql?


Database is HSQLDB. I have an existing sequence, say SEQ1. Now I want create another sequence SEQ2 that starts with the next value of SEQ1.

I tried

CREATE SEQUENCE SEQ2 START WITH SELECT NEXT VALUE FOR SEQ1;
CREATE SEQUENCE SEQ2 START WITH (SELECT NEXT VALUE FOR SEQ1);
CREATE SEQUENCE SEQ2 START WITH NEXT VALUE FOR SEQ1;
CREATE SEQUENCE SEQ2 START WITH (NEXT VALUE FOR SEQ1);

None of these seem to work however. Is there another way to achieve this in HSQLDB?


Solution

  • This is not currently possible. Only a numeric literal can be used after START WITH or after ALTER SEQUENCE seq RESTART WITH.