String Functions
String Operators
Table 1 lists common operation rules for string operators. A and B indicate string expressions.
| Operator | Returned Data Type | Description |
|---|---|---|
| A || B | STRING | Returns the string concatenated from A and B. |
| CHAR_LENGTH(A) | INT | Returns the number of characters in string A. |
| CHARACTER_LENGTH(A) | INT | Returns the number of characters in string A. |
| UPPER(A) | STRING | Returns the uppercase letter A. |
| LOWER(A) | STRING | Returns the lowercase letter a. |
| POSITION(A IN B) | INT | Returns the position where A first appears in B. |
| TRIM( { BOTH | LEADING | TRAILING } A FROM B) | STRING | Removes A at the start position, or end position, or both the start and end positions from B. By default, string expressions A at both the start and end positions are removed. |
| OVERLAY(A PLACING B FROM integer [ FOR B ]) | STRING | Replaces A with B. |
| SUBSTRING(A FROM integer) | STRING | Returns the substring that starts from a fixed position of A. The start position starts from 1. |
| SUBSTRING(A FROM integer FOR integer) | STRING | Returns the substring starting from a fixed position and with the given length A. The start position starts from 1. |
| INITCAP(A) | STRING | Returns the string whose first letter is in uppercase and the other letters in lowercase. Words are sequences of alphanumeric characters separated by non-alphanumeric characters. |
| MD5(String expr) | STRING | Returns the md5 value of a string. |
| SHA1(String expr) | STRING | Returns the SHA1 value of a string. |
| SHA256(String expr) | STRING | Returns the SHA256 value of a string. |
| replace(String expr, String toreplace, String replace) | STRING | Replaces all "toreplace" in the expr string with "replace". |
| hash_code(String expr) | INT | Obtains the hash value. In addition to string, the parameter supports int, bigint, float, and double. |
| string_to_array(value, delimiter) | Array[String] | Separates the "value" string as character string arrays by using the delimiter. |
| CONCAT(String A, String B, ...) | STRING | Returns the concatenation result of two or more strings. |
| CONCAT_WS(String separator, String A, String B, ....) | STRING | Returns the concatenation result of two or more strings and uses separator as the delimiter to connect each string. |
| RPAD(String str, INT len, String pad) | STRING | Concatenates the pad string to the right of the str string until the length of the new string reaches the specified length len.
|
| LPAD(String str, INT len, String pad) | STRING | Concatenates the pad string to the left of the str string until the length of the new string reaches the specified length len.
|
Last Article: Mathematical Operation Functions
Next Article: Time Functions
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.