Convert all primary keys to BIGINT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
execute block returns (constraint_name char(31),field_name char(31),table_name char(31)) as declare cur cursor for ( select rc.rdb$constraint_name as constraint_name, sg.rdb$field_name as field_name, rc.rdb$relation_name as table_name from rdb$indices ix left join rdb$index_segments sg on ix.rdb$index_name = sg.rdb$index_name left join rdb$relation_constraints rc on rc.rdb$index_name = ix.rdb$index_name where rc.rdb$constraint_type = 'PRIMARY KEY' ); begin open cur; while (1=1) do begin fetch cur into constraint_name, field_name, table_name; EXECUTE statement 'ALTER TABLE "' || :table_name ||'" DROP CONSTRAINT "'||:constraint_name||'";'; EXECUTE statement 'ALTER TABLE "' || :table_name ||'" ALTER COLUMN "'||:field_name||'" TYPE BIGINT;'; EXECUTE statement 'ALTER TABLE "' || :table_name ||'" ADD CONSTRAINT "'||:constraint_name||'" PRIMARY KEY ("'||:field_name||'");'; if (row_count = 0) then leave; suspend; end close cur; end |