Subject | Re: Altering column widths when don't know column names? |
---|---|
Author | stegt |
Post date | 2010-08-19T11:21:37Z |
You are a star. I think this would work. I never thought of using the system tables to help.
Thanks very much. :)
Thanks very much. :)
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær <svein.erling.tysvaer@...> wrote:
>
> MAYBE this will create a usable script:
>
> select 'alter table ' || rf.rdb$relation_name || ' alter ' || rf.rdb$field_name || ' type char(255);'
> from rdb$fields f
> join rdb$relation_fields rf on f.rdb$field_name = rf.rdb$field_source
> join rdb$relations r on rf.rdb$relation_name = r.rdb$relation_name
> where r.rdb$view_blr is null
> and (r.rdb$system_flag is null or r.rdb$system_flag = 0)
> and f.rdb$field_length = 100
> order by rf.rdb$relation_name, rf.rdb$field_position;
>
> I wrote maybe with capital letters because I don't know too much about the system tables, haven't tried it at all, don't know about side effects (what if there are VARCHAR(100) or other types with the same field length - you might not want to change them to CHAR, so you might want to add something like 'and f.rdb$field_type = 14' or similar to the WHERE clause) and am uncertain which other things might be affected (could the fields be primary or foreign keys, are they indexed or used in stored procedures/triggers etc, and does that matter with such an update or not?).
>
> Set