- Hi, I want to add a unique, non-nullable column to a table.
- It already has data. I would therefore like to instantly populate the new column with unique values, eg 'ABC123', 'ABC124', 'ABC125', etc.
- The data will eventually be wiped and replaced with proper data, so i don't want to introduce a sequence just to populate the default value.
Is it possible to generate a default value for the existing rows, based on something like rownumber()? I realise the use case is ridiculous but is it possible to achieve... if so how?
...
foo text not null unique default 'ABC'||rownumber()' -- or something similar?
...