This article mainly describes how to set and correctly modify character sets in the DB2 database. There are three levels of Character Set settings in the DB2 database, the system-level and instance-level character sets can be modified as needed, while database-level datasets must be determined during database creation.
In the DB2 database, Character Set-related problems mainly involve three levels of Character Set settings. The system-level and instance-level character sets can be modified as needed, database-level datasets must be determined during database creation.
(1) Operating System Locale: system-level code page setting determines the default code page of the application;
If you want to set OS Locale to Chinese, consider the following method:
Unix: You can use the export LANG = "zh_CN" command to modify the current Locale to Chinese;
Windows: Choose "start"> "Settings"> "Control Panel"> "region options" to set the system language;
(2) DB2CODEPAGE: the code page setting at the DB2 instance level, which affects the DB2 application to determine the code page when converting the code page.
You can use the db2set DB2CODEPAEG = command to set DB2CODEPAGE to the character set you need.
(3) database codepage: Specifies the DB2 DATABASE-level code page. It must be set at the time of DATABASE creation.
When creating a database, you must specify the required code page:
- db2 "CREATE DATABASE dbname USING CODESET UTF-8 TERRITORY CN"
Note: This statement can be used to create a Unicode database with the specified region as China (CN.
The above content is an introduction to the settings and modification of character sets at the three levels of the DB2 database.