Unicode Collation Algorithm-based collations
The CREATE DATABASE command and the COLLATION_KEY_BIT scalar function support the CLDRCOLL collation keyword. This keyword implements the UCA (Unicode Collation Algorithm) specified in the Unicode Standard and based on the Common Locale Data Repository (CLDR).
Db2® uses the open-source, International Components for Unicode (ICU) implementation of the UCA algorithm. ICU uses the tailoring rules for different locales and languages supplied by Unicode Common Locale Data Repository (CLDR).
Each updated version of ICU can include bug fixes, security fixes and updated CLDR data and algorithms that describe a language. Updating ICU versions can impact sorting and comparison rules on objects using string types.
For databases that have already been created using UCA collations in releases earlier than Db2 12.1, the versions of ICU that those databases were created at are not supported and there are some recommended steps to take before and after the database upgrade to ensure that the database and its objects are positioned to work as expected with the new release of ICU. For more information, see Upgrading databases that use unsupported UCA-based collations.
The default Unicode Collation Algorithm is implemented by the CLDRCOLL keyword without any attributes. Since the default UCA cannot simultaneously encompass the collating sequence of every language supported by Unicode, optional attributes can be specified to customize the UCA ordering. The attributes are separated by the underscore (_) character. The CLDRCOLL keyword and any attributes form a UCA collation name.
The following table describes the collation attributes, their values, and typical usage examples.
| Attribute name | Attribute short form | Valid values | Description |
|---|---|---|---|
Locale:
|
Locale:
|
See Table 2 for a list of all the valid Locale names. |
The Locale attribute is probably the most important attribute to obtain ordering that conforms to the user expectations in different countries and regions. You need to specify the Locale attribute to properly collate text for a specific language. The Locale attribute consists of the following parts:
Examples:
|
| Strength | S | 1, 2, 3, 4, or I |
The The possible values are: primary (1), secondary (2), tertiary (3), quaternary (4), and identity
(I). To ignore:
Almost all characters can be distinguished by the first three strength levels, so for most
locales the default Setting the Strength attribute to higher level slows down text string comparisons and increase the length of the sort keys. Examples:
|
| Case Level | E |
|
Setting the Case Level attribute to on and the Strength attribute to primary level will ignore accent but not case. The Case Level attribute is set to X by default in most locales. When this attributes is set to O, it will slightly affect text string comparisons performance and lengthen the sort keys. Examples:
|
| Case First | C | X, L, or U |
The Case First attribute controls whether upper case characters collate before or after lower case characters, in the absence of other differences in the two text strings. The possible values are upper case first (U), lower case first (L), and off (X). There is almost no difference between the lower case first setting and the off setting, therefore typically there is no need to use the lower case first setting. Specifying a Case First attribute of U or L can increase the length of the sort keys. Examples:
|
| Alternate | A | N or S |
The Alternate attribute controls the handling of variable characters in the UCA: white space, punctuation marks, and symbols. If the Alternate attribute is set to non-ignorable (N), then differences among these variable characters are of the same importance as differences among non-variable characters such as the English alphabet. If the Alternate attribute is set to shifted (S), then these variable characters are of only minor importance. If the Alternate attribute is set to shifted and the Strength attribute is set to the quaternary level, then variable characters are considered in a comparison when all other aspects of the strings - base letters, accents, and case - are identical. The default for most locales is non-ignorable. If shifted is selected, performance will be slower if there are many strings that are identical except for punctuation marks. Sort key length will not be affected unless the strength level is also increased. Examples:
|
| Variable Top | T | [4 or 8 UTF-16BE hexadecimal digits] |
The Variable Top attribute controls which characters to ignore, and is only meaningful if the Alternate attribute is set to Shifted. All characters whose primary weight is equal or lower than the specified character are considered ignorable. The character is specified as one or two UTF-16BE code units in hexadecimal notation. A Unicode supplementary character is specified using a surrogate pair. For example, if you want to ignore white space characters and not visible characters, then set the Alternate attribute to Shifted and this attribute to U+0020 (space) or U+3000 (ideographic space). Since all characters having the same primary weight are equivalent, so setting this attribute to U+0020 is equivalent to setting it to U+3000. This attribute alone has little impact on text string comparison performance but setting it higher makes sort keys longer. Example:
|
| Normalization Checking | N |
|
The Normalization Checking attribute, if set to O, will normalize the input text if necessary.
Even if this attribute is set to X, as is the default for many locales, text as represented in
common usage will collate correctly. You should, however, set this attribute to O in two cases:
There is a medium string comparison performance cost if this attribute is set to O, depending on
the frequency of sequences that require normalization. There is no significant effect on length of
the sort keys. If the text is already in normalized form NFD or NFKD, then you can set this
attribute to X to improve performance.
Examples:
|
| French | F |
|
The French sorts strings by examining the accents starting from the end of the string. This attribute is automatically set to O for the French locales, and has a minor performance cost for text string comparisons, but no change in the length of the sort keys. Examples:
|
| Hiragana | H |
|
The Hiragana attribute determines whether to distinguish between Japanese Hiragana and Katakana characters. To conform with the Japanese JIS X 4061 standard, you need to set this attribute to O and the Strength attribute to the quaternary level. This will, however, slow down text string comparisons and increase the length of the sort keys. Examples:
|
Valid locale names for the collations are shown in Table 2. The Default collation attributes column shows the full name of the collation for the specific locale. For example, CLDRCOLL_LAR is equivalent to CLDRCOLL_LAR_AN_CX_EX_FX_HX_NX_S3.
| Locale Name | Language (Region) | Default Collation Attributes |
|---|---|---|
| CLDRCOLL_LAF | Afrikaans | CLDRCOLL_LAF_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LAR | Arabic | CLDRCOLL_LAR_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LAR_KCOMPAT | Arabic | CLDRCOLL_LAR_KCOMPAT_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LAS | Assamese | CLDRCOLL_LAS_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LAZ | Azerbaijani | CLDRCOLL_LAZ_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LAZ_KSEARCH | Azerbaijani | CLDRCOLL_LAZ_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LBE | Belarusian | CLDRCOLL_LBE_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LBG | Bulgarian | CLDRCOLL_LBG_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LBN | Bengali | CLDRCOLL_LBN_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LBN_KTRADITIONAL | Bengali | CLDRCOLL_LBN_KTRADITIONAL_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LBS | Bosnian | CLDRCOLL_LBS_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LBS_KSEARCH | Bosnian | CLDRCOLL_LBS_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LBS_ZCYRL | Bosnian | CLDRCOLL_LBS_ZCYRL_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LCA_KSEARCH | Catalan | CLDRCOLL_LCA_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LCS | Czech | CLDRCOLL_LCS_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LCS_KSEARCH | Czech | CLDRCOLL_LCS_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LCY | Welsh | CLDRCOLL_LCY_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LDA | Danish | CLDRCOLL_LDA_AN_CU_EX_FX_HX_NX_S3 |
| CLDRCOLL_LDA_KSEARCH | Danish | CLDRCOLL_LDA_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LDE_KSEARCH | German | CLDRCOLL_LDE_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LDE_KPHONEBOOK | German | CLDRCOLL_LDE_KPHONEBOOK_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LDE_RAT_KPHONEBOOK | German (Austria) | CLDRCOLL_LDE_RAT_KPHONEBOOK_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LDSB | Lower Sorbian | CLDRCOLL_LDSB_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LEE | Ewe | CLDRCOLL_LEE_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LEL | Greek | CLDRCOLL_LEL_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LEN_RUS | English (United States) | CLDRCOLL_LEN_RUS_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LEO | Esperanto | CLDRCOLL_LEO_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LES | Spanish | CLDRCOLL_LES_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LES_KSEARCH | Spanish | CLDRCOLL_LES_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LES_KTRADITIONAL | Spanish | CLDRCOLL_LES_KTRADITIONAL_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LET | Estonian | CLDRCOLL_LET_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LFA | Persian | CLDRCOLL_LFA_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LFA_RAF | Persian (Afghanistan) | CLDRCOLL_LFA_RAF_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LFI | Finnish | CLDRCOLL_LFI_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LFI_KSEARCH | Finnish | CLDRCOLL_LFI_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LFI_KTRADITIONAL | Finnish | CLDRCOLL_LFI_KTRADITIONAL_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LFIL | Filipino | CLDRCOLL_LFIL_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LFO | Faroese | CLDRCOLL_LFO_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LFO_KSEARCH | Faroese | CLDRCOLL_LFO_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LFR_RCA | French (Canada) | CLDRCOLL_LFR_RCA_AN_CX_EX_FO_HX_NX_S3 |
| CLDRCOLL_LGL | Galician | CLDRCOLL_LGL_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LGL_KSEARCH | Galician | CLDRCOLL_LGL_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LGU | Gujarati | CLDRCOLL_LGU_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LHA | Hausa | CLDRCOLL_LHA_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LHAW | Hawaiian | CLDRCOLL_LHAW_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LHE | Hebrew | CLDRCOLL_LHE_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LHE_KSEARCH | Hebrew | CLDRCOLL_LHE_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LHI | Hindi | CLDRCOLL_LHI_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LHR | Croatian | CLDRCOLL_LHR_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LHR_KSEARCH | Croatian | CLDRCOLL_LHR_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LHSB | Upper Sorbian | CLDRCOLL_LHSB_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LHU | Hungarian | CLDRCOLL_LHU_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LHY | Armenian | CLDRCOLL_LHY_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LIG | Igbo | CLDRCOLL_LIG_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LIS | Icelandic | CLDRCOLL_LIS_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LIS_KSEARCH | Icelandic | CLDRCOLL_LIS_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LJA | Japanese | CLDRCOLL_LJA_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LJA_KUNIHAN | Japanese | CLDRCOLL_LJA_KUNIHAN_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LKK | Kazakh | CLDRCOLL_LKK_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LKL | Kalaallisut | CLDRCOLL_LKL_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LKL_KSEARCH | Kalaallisut | CLDRCOLL_LKL_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LKM | Khmer | CLDRCOLL_LKM_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LKN | Kannada | CLDRCOLL_LKN_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LKN_KTRADITIONAL | Kannada | CLDRCOLL_LKN_KTRADITIONAL_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LKO | Korean | CLDRCOLL_LKO_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LKO_KSEARCH | Korean | CLDRCOLL_LKO_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LKO_KUNIHAN | Korean | CLDRCOLL_LKO_KUNIHAN_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LKO_KSEARCHJL | Korean | CLDRCOLL_LKO_KSEARCHJL_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LKOK | Konkani | CLDRCOLL_LKOK_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LKY | Kyrgyz | CLDRCOLL_LKY_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LLKT | Lakota | CLDRCOLL_LLKT_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LLN | Lingala | CLDRCOLL_LLN_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LLN_KPHONETIC | Lingala | CLDRCOLL_LLN_KPHONETIC_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LLT | Lithuanian | CLDRCOLL_LLT_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LLV | Latvian | CLDRCOLL_LLV_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LMK | Macedonian | CLDRCOLL_LMK_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LML | Malayalam | CLDRCOLL_LML_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LMR | Marathi | CLDRCOLL_LMR_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LMT | Maltese | CLDRCOLL_LMT_AN_CU_EX_FX_HX_NX_S3 |
| CLDRCOLL_LMY | Burmese | CLDRCOLL_LMY_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LNB | Norwegian Bokmål | CLDRCOLL_LNB_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LNB_KSEARCH | Norwegian Bokmål | CLDRCOLL_LNB_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LNN | Norwegian Nynorsk | CLDRCOLL_LNN_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LNN_KSEARCH | Norwegian Nynorsk | CLDRCOLL_LNN_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LOM | Oromo | CLDRCOLL_LOM_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LOR | Oriya | CLDRCOLL_LOR_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LPA | Punjabi | CLDRCOLL_LPA_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LPL | Polish | CLDRCOLL_LPL_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LPS | Pashto | CLDRCOLL_LPS_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LRO | Romanian | CLDRCOLL_LRO_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LROOT | Root | CLDRCOLL_LROOT_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LRU | Russian | CLDRCOLL_LRU_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LSE | Northern Sami | CLDRCOLL_LSE_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LSE_KSEARCH | Northern Sami | CLDRCOLL_LSE_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LSI | Sinhala | CLDRCOLL_LSI_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LSI_KDICTIONARY | Sinhala | CLDRCOLL_LSI_KDICTIONARY_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LSK | Slovak | CLDRCOLL_LSK_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LSK_KSEARCH | Slovak | CLDRCOLL_LSK_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LSL | Slovenian | CLDRCOLL_LSL_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LSMN | Inari Sami | CLDRCOLL_LSMN_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LSMN_KSEARCH | Inari Sami | CLDRCOLL_LSMN_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LSQ | Albanian | CLDRCOLL_LSQ_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LSR | Serbian | CLDRCOLL_LSR_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LSR_ZLATN | Serbian | CLDRCOLL_LSR_ZLATN_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LSR_ZLATN_KSEARCH | Serbian | CLDRCOLL_LSR_ZLATN_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LSV | Swedish | CLDRCOLL_LSV_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LSV_KSEARCH | Swedish | CLDRCOLL_LSV_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LTA | Tamil | CLDRCOLL_LTA_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LTE | Telugu | CLDRCOLL_LTE_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LTH | Thai | CLDRCOLL_LTH_AS_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LTO | Tongan | CLDRCOLL_LTO_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LTR | Turkish | CLDRCOLL_LTR_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LTR_KSEARCH | Turkish | CLDRCOLL_LTR_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LUG | Uyghur | CLDRCOLL_LUG_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LUK | Ukrainian | CLDRCOLL_LUK_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LUR | Urdu | CLDRCOLL_LUR_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LVI | Vietnamese | CLDRCOLL_LVI_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LVI_KTRADITIONAL | Vietnamese | CLDRCOLL_LVI_KTRADITIONAL_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LYI | Yiddish | CLDRCOLL_LYI_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LYI_KSEARCH | Yiddish | CLDRCOLL_LYI_KSEARCH_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LYO | Yoruba | CLDRCOLL_LYO_AN_CX_EX_FX_HX_NO_S3 |
| CLDRCOLL_LZH | Chinese | CLDRCOLL_LZH_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LZH_KUNIHAN | Chinese | CLDRCOLL_LZH_KUNIHAN_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LZH_KBIG5HAN | Chinese | CLDRCOLL_LZH_KBIG5HAN_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LZH_KGB2312HAN | Chinese | CLDRCOLL_LZH_KGB2312HAN_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LZH_KSTROKE | Chinese | CLDRCOLL_LZH_KSTROKE_AN_CX_EX_FX_HX_NX_S3 |
| CLDRCOLL_LZH_KZHUYIN | Chinese | CLDRCOLL_LZH_KZHUYIN_AN_CX_EX_FX_HX_NX_S3 |
Details of the Unicode Collation Algorithm can be found in the Unicode Technical Standard, available at the Unicode Consortium website.
Discontinued collations introduced before Db2 12.1
- UCA400_NO, UCA400_LSK, and UCA400_TH
- UCA400R1
- UCA500R1
- CLDR181
- CLDR2701