db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Murphy <jim.mur...@pobox.com>
Subject Generate primary key ids on insert?
Date Sat, 12 Jan 2008 15:50:39 GMT

I'm writing a transformation script to migrate older DB instances to our new
schema.  PArt of that requires inserting data from one table into another:

insert into foo select a,b,c from bar

My touble is that foo has a primary key column 'id' that needs id values
set.  I have NOT parked this calumn as auto incrementing since when the db
is really in use the incrementing is done by hibernate and the state stored
int he hibernate_unique_key tabel that holds the current hi value.

Anyone know of some modification to the insert statement that would allow me
to generate an integer?  I know the valid ranges, I just need to be able to
insert a different valid int for each row.  This might be a stupid question
that is solved with simple sql - but this is not my forte so hopefully I'm
missing the easy answer.

FWIW, I'm toyed with the idea of altering the table's ID column (add
increment by) for the transform then alter it back but there doesn't seem to
be a way to "drop" increment by - but please correct me if I'm wrong on

View this message in context: http://www.nabble.com/Generate-primary-key-ids-on-insert--tp14775039p14775039.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.

View raw message