Subject RE: [firebird-support] Updating field length
Author Alan McDonald
> I have a VarChar field that I want to increase the length of (from 4 to
> 6). I run:
>
> ALTER TABLE MYTABLE ALTER MYFIELD TYPE VARCHAR(6);
>
> Now I get an error because it's used in stored procedures and triggers.
> So I have two options:
>
> 1) Drop all stored procedures/triggers, alter the field, and finally add
> back my stored procedures/triggers
> 2) Run the following:
> UPDATE RDB$FIELDS SET RDB$FIELD_LENGTH = 6,
> RDB$CHARACTER_LENGTH = 6,
> RDB$CHARACTER_SET_ID = NULL
> WHERE RDB$FIELD_NAME = (SELECT RDB$FIELD_SOURCE
> FROM RDB$RELATION_FIELDS
> WHERE RDB$RELATION_NAME = 'MYTABLE' AND
> RDB$FIELD_NAME = 'MYFIELD')
>
> This is something that will run in a script at users locations. Is
> there a preferred method for this?

number 1 is the preferred method. But if you proceed with 2, make sure you
try a backup and restore cycle on your test copy to make sure you don't end
up with a database which will never restore. It may work OK, and even backup
OK but may never restore after fiddling with system tables directly.
Alan