Purpose
SUBSTRB() extracts a substring from a string in bytes.
Syntax
SUBSTRB(char, position [, substring_length])
Parameters
Parameter |
Description |
|---|---|
| char | The string from which to extract a substring. |
| position | The starting byte position for extraction. A value of 0 is treated as 1. If the value is negative, the starting position is counted backward from the end of the string. |
| substring_length | Optional. The number of bytes to extract. If this parameter is omitted, the function extracts through the end of the string. |
Return type
The return type is a string.
Examples
In the UTF-8 string éOceanBase, the character é occupies 2 bytes. The following example extracts 5 bytes starting from the third byte:
obclient> SELECT SUBSTRB('éOceanBase', 3, 5) AS result FROM DUAL;
+--------+
| RESULT |
+--------+
| Ocean |
+--------+
1 row in set