java - JavaDB - autoincrement among several tables -
is possible have autoincrementing id among several tables?
what mean - have (let's five) tables, 1 of them table containing information sales (sale_id, sold_item_id) , 4 contain info different kind of sold stuff. want these 4 share 1 pool of ids. how do that?
edit.
decided choose juxhin solution , created additional table. everytime create record in 1 of these 4 tables, autoincrement new id in additional table , id in 1 of columns of new row.
this sounds use case sequence , link seems indicate javadb supports this.
so create 1 common sequence tables:
create sequence masequence and use when inserting tables:
insert tab1(id,....) values(next value mysequence,...) each next value advance sequence , ids unique across tables.
Comments
Post a Comment