| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Add Sequential Number to Column
I need to update a non-uniquely indexed column with a sequential
number. I think I can do it with the following statement, but I am
concerned about performance, since there are about 3 million rows. Is
there a faster way to do it than SQL?
update mytable t
set sequence_nbr = ( select count(rowid)
from mytable t2
where t2.name = t.name
and t2.starting_date = t.starting_date
and t2.rowid <= t.rowid)
where exists ( select NULL
from mytable t3
where t3.name = t.name
and t3.starting_date = t.starting_date
and t3.rowid <> t.rowid)
Received on Mon Oct 08 2001 - 13:03:58 CDT
![]() |
![]() |