I have to modify an existing table in a Oracle 10g DB with a few thousand records to add a surrogate autonumber key. One way that comes to my mind is to
- Create a new sequence
- Create the id column, allowing null values
- Updating the id column with the sequence
- Alter table to add "not null" and "primary key" for the new id column
Is there an easier or more efficient way of doing this (or is there some reason why this wouldn't work)?