Search code examples
sqlfirebirdfirebird2.5

Change default collation for Firebird database and tables


I have a Firebird database with charset WIN1251. The database already has several tables. Now I want to change the default collation to WIN1251_UA. So I had executed this statement:

ALTER CHARACTER SET WIN1251 SET DEFAULT COLLATION WIN1251_UA

According to this link query above changes the default collation for the database.

Now, I'm faced with a problem, for all tables all varchar fields still have collation WIN1251. How can I change default collation for all existing tables too?

I'm using Firebird 2.5.


Solution

  • Finally I found the solution. For example if i want to change collation for all txt fields in all tables. I can do this with this query:

    update RDB$RELATION_FIELDS set
    RDB$COLLATION_ID = 2
    where  rdb$view_context is null and rdb$field_name='TXT';
    

    Of course query above will fail if txt field in some table is a part of integrity constraint.

    In this manner I can change other fields which used in sort clause.