How to set charset UTF8?

4

I have a database that was created using Firebird 1.0, at that time there was no available UTF8 charset, only from version 2.0 it was possible, so we left charset none.

Questions:

1 ° How can I define UTF8 charset? remembering that the charset is set in all columns.

2 ° Resetting this encoding can corrupt existing data?

    
asked by anonymous 29.01.2016 / 16:05

1 answer

3

To set charset in firebird should be in database creation

CREATE DATABASE <database> 
  USER <username> 
  PASSWORD <password> 
  PAGE_SIZE <pagesize> 
  DEFAULT CHARACTER SET <charset>

See an example below:

CREATE DATABASE localhost:meter
  USER SYSDBA
  PASSWORD masterkey
  PAGE_SIZE 4096
  DEFAULT CHARACTER SET UTF8;

To change an existing charset

ALTER CHARACTER SET charset SET DEFAULT COLLATION collation

See the example:

alter character set utf8 set default collation unicode_ci_ai

If you use SET DEFAULT COLLATION on the default character set of the database, you have effectively defined the default collation for the database. If you use SET DEFAULT COLLATION in the connection character set, the string constants will be interpreted according to the new default collation. In most situations, this will not make any difference, but comparisons can have another result if the grouping changes.

    
25.02.2016 / 12:47