Subject Re: [firebird-support] Changing database charset
Author Fabiano Bonin
> You could mess with system tables, but I dont think it's a good ideia.
> Besides you need to inactivate/reactivate all the indices (wich is
> impossible for FK and PK)
>
> If I were you I would extract the metadata, change it, create an empty
> database, and use IBPump to pump the data.

I manage several complex and different databases, and pump all them is
not an option for me now, so i need to investigate the mess with
system tables approach... :-)

I'm testing with a table named CAD1, which has a column named NOME. I
need to change the charset to ISO8859_1 and the collation to PT_BR.
Can i consider a 'safe' procedure to run the script below in single
user mode, and then backup/restore the database before using it?

-- change charset and collation of the column domain

update rdb$fields a set
a.rdb$character_set_id = 21,
a.rdb$collation_id = 16
where
a.rdb$field_name = (
select
b.rdb$field_source
from
rdb$relation_fields b
where
b.rdb$relation_name = 'CAD1'
and b.rdb$field_name = 'NOME' );

-- change charset of the column

update rdb$relation_fields a set
a.rdb$collation_id = 16
where
a.rdb$relation_name = 'CAD1'
and a.rdb$field_name = 'NOME';

Regards,

Fabiano.