Subject Change Datatype
Author Christian
Hello,

I have some tables with primary key column of datatype SMALLINT. Now I
want to change the datatype of the primary key column to INTEGER. Sure
there are a lot of tables with foreign key reference to the SMALLINT
column. So I have to change also these columns but hopefully with small
effort.

CREATE TABLE salutation (
ID SMALLINT NOT NULL
...);
ALTER TABLE salutation ADD PRIMARY KEY (ID);

CREATE TABLE customer (
ID INTEGER NOT NULL,
SALUTATION SMALLINT,
...);
ALTER TABLE customer ADD PRIMARY KEY (ID);
ALTER TABLE customer ADD CONSTRAINT FK_CUST_SALUT
FOREIGN KEY (salutation) REFERENCES salutation (ID)
ON DELETE SET NULL ON UPDATE CASCADE;


Causes following statements any problems:

CREATE DOMAIN D_INTEGER AS INTEGER;

update RDB$RELATION_FIELDS set
RDB$FIELD_SOURCE = 'D_INTEGER'
where (RDB$FIELD_NAME = 'ID') and
(RDB$RELATION_NAME = 'SALUTATION')
;

update RDB$RELATION_FIELDS set
RDB$FIELD_SOURCE = 'D_INTEGER'
where (RDB$FIELD_NAME = 'SALUTATION') and
(RDB$RELATION_NAME = 'CUSTOMER')
;

Kind regards,
Christian