Search code examples
sqlhsqldb

HSQLDB - link several sequences for several columns of the table


I would like to link several sequences for generating default values for several columns of a table.

For example:

CREATE SEQUENCE seq1 START WITH 1;
CREATE SEQUENCE seq2 START WITH 1;
CREATE TABLE mytable (rid int GENERATED BY DEFAULT AS SEQUENCE seq1 PRIMARY KEY, p63 int GENERATED BY DEFAULT AS SEQUENCE seq2)

Unfortunately, an error is occured: "identity definition not allowed"

In Postgresql is working.

Any idea ?

Thanks


Solution

  • The first use of the sequence is allowed. You can write a BEFORE INSERT TRIGGER to insert sequence values into the second column.