Subject | Re: [firebird-support] Altering the length of VARCHAR column |
---|---|
Author | Aage Johansen |
Post date | 2005-06-01T20:17:42Z |
Christian Gütter wrote:
alter table TABLENAME
alter FIELDNAME type varchar(50)
or something such.
Unless you have a prehistoric version of InterBase. In those days I used
to use:
update rdb$fields
set rdb$field_length = <NEW LENGTH>,
rdb$character_length = <NEW LENGTH>
where rdb$field_name =
(select rdb$field_source
from rdb$relation_fields
where rdb$relation_name = '<TABLENAME>'
and rdb$field_name = '<TABLENAME>'
)
assuming you use 1-byte characters (and like to live dangerously).
And, don't try to make it shorter.
--
Aage J.
> Hi,Isn't there a
>
> I have to enlarge a VARCHAR column from 20 to 50 chars.
> As this column is referenced by many triggers and SPs, I cannot
> just delete and recreate it by using a helper field.
>
> I could perhaps do it like that:
>
> update RDB$FIELDS set
> RDB$FIELD_LENGTH = 50,
> RDB$CHARACTER_LENGTH = 50
> where RDB$FIELD_NAME = 'RDB$353'
>
> Many direct modifications of system tables are dangerous, so I would
> rather avoid this. Is there another way? Or can somebody confirm that
> the above query is not dangerous?
alter table TABLENAME
alter FIELDNAME type varchar(50)
or something such.
Unless you have a prehistoric version of InterBase. In those days I used
to use:
update rdb$fields
set rdb$field_length = <NEW LENGTH>,
rdb$character_length = <NEW LENGTH>
where rdb$field_name =
(select rdb$field_source
from rdb$relation_fields
where rdb$relation_name = '<TABLENAME>'
and rdb$field_name = '<TABLENAME>'
)
assuming you use 1-byte characters (and like to live dangerously).
And, don't try to make it shorter.
--
Aage J.