Unique Keys on Corrupt Serial Fields
Posted in 1994
Topics: Migration, Import/Export & Data Conversion
I have a customer who (somehow) got duplicate values in a SERIAL field
that is keyed uniquely. I need to figure out a way to rebuild his data
file and make the values in the SERIAL field unique. I have tried
DROPping the column, ADDing it back as type integer, then MODIFYing it
to type SERIAL but the data in the column is still not unique. I don't
want to UNLOAD the table, write a program to change the serial field's
value in the unloaded ascii file to a unique number (record number), and
then insert the data back into the data file, unless that is the only way to
do it. If I could simply do something like this:
alter table univ drop (un_sys_no);
alter table univ add( un_sys_no integer);
update univ set un_sys_no = [some unique value [record_no()?]];
alter table univ modify( un_sys_no serial NOT NULL);
my problem would be solved but I don't know how to set a unique value
into un_sys_no after it as been dropped and then added. Any help would
be greatly appreciated!
Thanks.