Changing database structure by Adding Primary Key field SQL 11g
Posted on 2014-10-28
Greetings Experts -
Today a general discussion question.
I have inherited a database an Oracle 11g database with NO primary key field.
Instead an external identifier with a not null constraint was used to relate all the tables, run the forms and update the records.
As is the fate of all external identifiers, it is now being superseded and will no longer be available to my inherited database. Even better--not every record in the inherited database will be assigned a new external identifier.
Ideally, I would like to migrate the old external identifier into a new field, and modify its former field to a primary key field with an autonumber sequence. By reusing the field I hope to avoid having to rewrite all of the tables/queries and forms.
I am unclear as to the method and timing of updating the related tables. Should I create a new temporary field in the 'base' table so that I maintain integrity while I update the related child tables? Other pitfalls? Is this an accepted approach? Are there others?