How to set UTF8 charset?

Asked

Viewed 1,161 times

4

I have a database that was created using Firebird 1.0, at this time there was no UTF8 charset available, only from version 2.0 was having this possibility, so we left the None charset.

Doubts:

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

2° Resetting this code can damage existing data ?

1 answer

3


To set the charset in Firebird must be in the 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

Take 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 grouping for the database. If you use SET DEFAULT COLLATION in the connection character set, the string constants will be interpreted according to the new standard grouping. In most situations, this will make no difference, but comparisons may have another result if the grouping changes.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.