Column substrings in multibyte code sets
For multibyte code sets, column substrings return the specified number of bytes, not the number of characters.
If a character column multi_col contains a string
of three 2-byte characters, this 6-byte string can be represented
as follows:
A1A2B1B2C1C2
Suppose
that a query specified this substring from the multi_col column:
multi_col[1,2]
The
query returns the following result:
A1A2
The returned substring consists of 2 bytes (one character), not two characters.
To
retrieve the first two characters from the multi_col column,
specify a substring in which first is the position of the first
byte in the first character and last is the position of the
last byte in the second character. For the 6-byte string A1A2B1B2C1C2,
this g expression specifies the substring in your query:
multi_col[1,4]
The following
result is returned:
A1A2B1B2
The substring that the query returns consists of the first 4 bytes of the column value, representing the first two logical characters in the column.