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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Adding a Sequence to an existing table

Re: Adding a Sequence to an existing table

From: Steve McDaniels <steve.mcdaniels_at_sierra.com>
Date: Mon, 16 Jul 2001 16:43:53 -0700
Message-ID: <9ivu42$1e5$1@spiney.sierra.com>

add the sequence column (alter table...)

update Table set sequence_column = rownum -- populate existing rows /

select max(sequence_column) from Table -- find max /

create sequence seq_T start with MAX_FROM_ABOVE+1 /

create trigger on Table
for each row
before insert
begin
  select seq_T.nextval into :new.sequence_column from dual; end;
/

to populate
"Paul" <paul_merlin_at_hotmail.com> wrote in message news:bf31b525.0107160416.7c6b5f3c_at_posting.google.com...
> Hi,
>
> I need to add a sequence column to a table that currently has approx
> 3000 rows.
> I cannot change the name of the table as it is used by a number of
> different applications.
>
> Can anybody offer any advice.
>
> Thanks,
>
> Paul
Received on Mon Jul 16 2001 - 18:43:53 CDT

Original text of this message

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