Firebird Default Character Set

SQL select command

SELECT a.RDB$CHARACTER_SET_NAME FROM RDB$DATABASE a 

returns null. What character set is used if it is not specified when creating a new database? Is there a difference between the different versions of Firebird (1.0, 2.0, 2.5.1, etc.)?

+7
source share
1 answer

The default character set for the database, when the character set was not specified at the time of creation, has the NONE character set, see page 47 of the Interbase 6.0 Data Definition Guide (available in the documentation section of the Firebird website). This was the same as before Firebird (possibly since the creation of Interbase) and still applies to existing versions. However, in Firebird 2.5, when the database is created without the default character set, then RDB$CHARACTER_SET_NAME will be NONE . I'm not sure what this was in previous versions, but so far I assume that it uses NONE by default, even if it reports NULL .

If you want to be sure, you can simply create a base table with a CHAR or VARCHAR column without a character set specification, and then use the following query to determine the default value:

 SELECT a.RDB$FIELD_NAME, a.RDB$RELATION_NAME, b.RDB$CHARACTER_SET_ID, c.RDB$CHARACTER_SET_NAME FROM RDB$RELATION_FIELDS a INNER JOIN RDB$FIELDS b ON b.RDB$FIELD_NAME = a.RDB$FIELD_SOURCE INNER JOIN RDB$CHARACTER_SETS c ON c.RDB$CHARACTER_SET_ID = b.RDB$CHARACTER_SET_ID WHERE RDB$RELATION_NAME = 'TABLE_NAME' 

You can use this to find the character set of any ( (VAR)CHAR ) BTW field.

The NONE character set means that character set assumptions do not exist, so you can store data in it in any character set. However, you cannot store or compare it with a column with an explicit character set (except, perhaps, the OCTETS character OCTETS , I'm not sure about that).

If you use NONE , you must always use the same connection character set when connecting to the database, or if you use the NONE character set as the connection character set so that your application, driver, component access or programming language always uses the same same encoding, otherwise you will get transliteration problems (problems with character encoding).

Using NONE , since the connection character set has additional problems. For example , column data will always be sent as is and stored as received , unless a combination of bytes is allowed in the character set of the column. Basically, this means that the database should be used in the same language environment in which it was created.

In general, it’s better to clearly indicate the default character set if you don’t know what you are doing.

+13
source

All Articles