views:

56

answers:

1

I have this table:

old_id integer NOT NULL,
new_id integer

Now I want to update new_id with a sequence in such a way that the order of old_id is preserved. Basically:

update table
set new_id = sequence.NEXTVAL
order by old_id

Is something like this possible? If it matters, I'm on Oracle 10g.

+3  A: 
update (select * from mytable order by old_id) set new_id = mysequence.nextval;
ammoQ
Cool, thanks! Finally a way to update more than a single table in one go!
Aaron Digulla