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

Home -> Community -> Usenet -> comp.databases.oracle -> Re: How to fill empty column with number sequence?

Re: How to fill empty column with number sequence?

From: Ed prochak <ed.prochak_at_magicinterface.com>
Date: 13 Feb 2004 11:17:08 -0800
Message-ID: <4b5394b2.0402131117.5226814c@posting.google.com>

ken1_at_tjohoo.se (Ken1) wrote in message news:<3bb6578e.0402130011.75bd6b51_at_posting.google.com>...
> I am going to drop a primary key from one column and create a new
> column to be used as primary key in an existing database.
> The old column was a date column which someone earlier though was a
> good candidate for a primary key which we all know it's not.
>
> Now I want to add a new field, i.e. called ID, with a normal number
> sequence as primary key.
>
> I have dropped the primary key, created the new column, created the
> new sequence and created a trigger to generate the primary key for new
> inserts.
>
> But I don't know how to generate/update the new ID column with
> sequence numbers for the already existing records.
>
> Any ideas?
>
> /Kenneth

A simple PL/SQL process can do it.
open the table for all rows,
count each row fetched,
 and update the ID to the count value.

HTH,
  ed Received on Fri Feb 13 2004 - 13:17:08 CST

Original text of this message

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