I have a database in Firebird 2.5 filled with data.
I need to change the character set from UTF-8
to ISO8859_1
, I tried:
alter database default character set ISO8859_1 collation ES_ES
But it doesn't work. How can I convert the character set?
Changing the default character set only affects columns created (without an explicit character set) after the change. Existing columns are unaffected as the character set is a property of each individual column. This means that you have to alter all (relevant) columns.
There are several problems
NONE
or OCTETS
).
Conversion from NONE
or OCTETS
to another character set may result in string conversion errors, or garbage because the content may not match your expectations, or maybe invalid bytes in the target character set.To address these problems you can do:
UPDATE table SET newcolumn = oldcolumn
(or if oldcolumn is NONE
or OCTETS
: UPDATE table SET newcolumn = cast(cast(oldcolumn as VARCHAR(...) CHARACTER SET assumedcharset) as VARCHAR(...) CHARACTER SET targetcharset)
This second option is only preferable if you want to change a small database (in terms of tables, columns and dependencies) or you need to perform odd conversions, otherwise I'd strongly suggest to use the data pumping solution.
ALTER CHARACTER SET ISO8859_1
SET default COLLATION ES_ES;
Script-Execute this to your active Database that you want to change!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With