Subject Re: Modify Primary key
Author Alexander V.Nevsky
--- In firebird-support@yahoogroups.com, "skotaylor" <scott@d...>
wrote:
> I need to add another field to a primary key on a live database. I
> added the record to the RDB$INDEX_SEGMENTS and all looks good except

Scott, I'm amazing why people don't like broad, paved with asphalt
roads and prefer circuitous wild pathes :) Why not just

Alter Table T Add NewCol Not Null;
Commit;
Update NewCol [series of statements to fill by needed values until
nulls are eleminated];
Commit;
Alter Table T Drop Constraint T_PK;
Commit;
Alter Table T Add Constraint T_PK Primary Key (OldCol, NewCol);
Commit;

if you have FKs on another tables references on this PK, you should
drop them before dropping it and re-create after creation new one.
Anyway, you should change them too. Perhaps you'll be forced to
reconnect several times due to "object in use" exception. Hacks of
system table is last what reasonables person should try to do, use
documented ways.

Best regards, Alexander.