I have a oracle repository up and running and has say 10 million records. One of the table is say
CREATE TABLE TABLE_A
NAME VARCHAR2(128),
VER VARCHAR2(128),
TYPE VARCHAR2(32),
DESCRIPTION VARCHAR2(256),
CONSTRAINT TABLE_A_PK PRIMARY KEY ("NAME","VERSION");
This table is being used for long and now say I have a requirement to change the primary key constraint. Now I have the requirement to have another column say ID and primary key to be combination of NAME, VER, TYPE and LANG.
In the upgrade script I can have something like
EXECUTE IMMEDIATE
ALTER TABLE TABLE_A ADD LANG VARCHAR2(32);
EXECUTE IMMEDIATE
UPDATE TABLE TABLE_A SET LANG ='|| 'en_US';
EXECUTE IMMEDIATE
UPDATE TABLE TABLE_A SET TYPE='||'n/a'||' WHERE TYPE IS NULL;
Before TYPE can have values and sometimes null. Since after upgrade its part of primary key it cannot be null so making it n/a if its null.
But doing above thing for 10 million records requires upgrade downtime of 5 hours atleast. Is there any other way I can make a previous column as primary key and still won't require much downtime. Kindly also suggest me if I am wrong with my approach. Thanks in Advance