I want to add a column to an existing legacy database and write a procedure by which I can assign each record a different value. Something like ad
This will depend on the database but for SQL Server, this could be achieved as follows:
alter table Example
add NewColumn int identity(1,1)
Depends on the database as each database has a different way to add sequence numbers. I would alter the table to add the column then write a db script in groovy/python/etc to read in the data and update the id with a sequence. Once the data has been set, I would add a sequence to the table that starts after the top number. Once the data has been set, set the primary keys correctly.