Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Add Sequential Number to Column

Add Sequential Number to Column

From: Buck Turgidson <jc_va_at_hotmail.com>
Date: 8 Oct 2001 11:03:58 -0700
Message-ID: <f98999c8.0110081003.43ffd234@posting.google.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US