-
update a null column with a sequence number
So, just back from the pub after dinner........
Got a table that is populated with 500K records. Requirement is to add a new column PURN, and populate it with a sequential number starting at 12 million.
So PURN would go from 12,000,000 to 12,500,000
Can't reload table, so must update in situ....
Help!!
Not that urgent by the way........
-
create sequence xxx starting with 12000000
then loop round updating ther column with next val
-
update t set new_Col = 12000000 + rownum;
select max(t) from t;
create sequence t_seq start with ;
Jeff Hunter
-
Thanks Guys, went for Jeff's simple rownum solution.
Old Peculiar has a way of clouding the mind......
-
Speckled Hen has a way of making you fall asleep at your desk...
-
Consider yourselves lucky. Some of us make do with lager and the occasional bottle of Newcastle Brown.
-
-
Why can't I work near a pub?
I'll have a Guinness, by the way.
-
Originally posted by marist89
update t set new_Col = 12000000 + rownum;
select max(t) from t;
create sequence t_seq start with ;
An easiest way is:
1. Create sequence starting on 12000000.
2. Add column to table
2. Update table column in a single DML:
UPDATE t
SET x_column = t_seq.nextval;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|