Insert multiple rows with a sequence

What is the best/proper way to insert multiple rows into a table that uses a sequence with an increment of 50 without ending up with a lot of gaps?

I‘ve tried few approaches but always got stuck manually handling the sequence or ended up with a lot of gaps in the IDs.

Bonus: It should work with Postgres and Hsqldb alike.


Hi @Firpo,

If I’m not misunderstanding your needs you might looking for something like this:

 <changeSet id=<ID> author=<AUTHOR>
        <createSequence sequenceName="seq_test" incrementBy="50" minValue="0" maxValue="100000"/>

CreateSequence change type is supported by Postgres and Hsql (docs: createSequence).

Please have a look at this and let us know if you have any further question.