Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate primary key from sequence in HSQLDB

Currently I am using HSQLDB 2.0.0 for my project.

I have a table with primary key and a sequence.

I would like to generate the primary key value from the sequence whenever a insert happens.

Is that possible by a trigger? If so could you let me know how this can be accomplished?

Regards,

Satya

like image 211
Satya Avatar asked Jan 16 '11 18:01

Satya


People also ask

Is HSQLDB same as H2?

However, HSQLDB highly outperforms H2 in DDL operations as well as when starting/shutting down the instance, even for a small database (due to H2's compiling stored functions afresh with javac at every database startup!). This depends on the way you store stored functions.

Is HSQLDB in-memory?

HSQLDB (HyperSQL DataBase) is the leading SQL relational database system written in Java. It offers a small, fast multithreaded and transactional database engine with in-memory and disk-based tables and supports embedded and server modes.

What does HSQLDB stand for?

HSQLDB (Hyper SQL Database) is a relational database management system written in Java.


1 Answers

Yes, you can do it with a trigger. See this question

Link a sequence with to an identity in hsqldb

like image 104
fredt Avatar answered Oct 06 '22 18:10

fredt