All string functions support Unicode characters. Functions that transform character case are locale-sensitive.
These functions support the UTF-8 format:
- RTRIM
- LTRIM
- LEFT
- RIGHT
- TRIM
- TRANSLATE
- RPAD
- LPAD
- SUBSTRING
Index position values for character and string functions begin at position
1. For example, the "H" in the string "Hello" is at position 1.ASCII
Returns the ASCII code value of the leftmost character of the character value.The ASCII function only supports ASCII characters in the input argument.
SQL
SQL
97
Example
SQL
98
BIT_LENGTH
Returns the length of the character value in bits. SyntaxSQL
SQL
8
Example
SQL
16
Example
SQL
24
BTRIM
Alias for TRIM.CHR
Converts an integer value to a string. The value is first sign-extended to 8 bytes. Then, if it can be represented as 1 byte, a string is returned with that one byte. Otherwise, a string is returned of length 2 bytes, 4 bytes, or 8 bytes with the bytes set to the big-endian representation of the integer, depending on how many high order zero bytes there are in the integer. SyntaxSQL
SQL
a
CHAR_LENGTH
Alias for LENGTH.CHARACTER_LENGTH
Alias for LENGTH.CONCAT
Concatenates two or more values, all of which must be binary, hash, or string data types. For strings, as long as one argument is a character value, the other arguments are implicitly cast to a character value. SyntaxSQL
Example
SQL
ocient data warehouse
Example
SQL
ocient data warehouse
ENDSWITH
Returnstrue if x ends with y and false otherwise.
Syntax
SQL
Example
SQL
true
Example
SQL
false
Example
SQL
true
INITCAP
For each word in the specified string, capitalize the first character if it is alphabetic. The system defines words as alphanumeric strings separated by non-alphanumeric characters. The system converts all other alphabetic characters to lowercase. SyntaxesSQL
INSTR
Returns the index position of the first occurrence where the character valuechar_substring appears in the character value char by ignoring the case.
Syntax
SQL
Example
SQL
1
SQL
8
JSON_EXTRACT_PATH_TEXT
Returns the value for the key-value pair referenced by a series of path elements in a JSON string. SyntaxSQL
Examples
Extract Values from Nested Paths
This example extracts the value based on two specified paths in the JSON string,
n4 and n6.
SQL
"circle"
Return NULL from Invalid JSON
In this example, the query requests the same nested paths, but the JSON is invalid because all of the keys lack quotation marks.
The query returns NULL because the null_if_invalid argument equals TRUE.
SQL
NULL
LCASE
Alias for LOWER.LEFT
Return the number of characters in the string equal of the valueinteger. If integer is negative, the function returns all but the last integer characters.
Syntax
SQL
Example
SQL
ocient d
Example
SQL
ocient data wareho
LENGTH
Alias for CHAR_LENGTH and CHARACTER_LENGTH. Returns the length of the value. For character data types, this value is in terms of characters. For binary data types, this value is in terms of bytes. SyntaxSQL
SQL
21
LOCATE
Alias for POSITION. Returns the index position of the first occurrence of the character valuesubstring in the character value string.
Optionally, you can also include an additional value offset to offset the LOCATE function by the specified number of spaces.
Index positions begin at 1.
Syntax
SQL
Example
SQL
13
Example
SQL
4
Example
In this example, the index starts at position 5. This means the function skips the initial 'e' in the string. Instead, it returns the second e at index position 15.
SQL
15
LOWER
Alias for LCASE. Convert string to lowercase. SyntaxSQL
SQL
ocient
Example
SQL
ocient
LPAD
Pad the input text to the specified length with the pad string on the left side. If text is longer than length, it is truncated tolength characters. If the argument pad is not provided, the space character is used.
Syntax
SQL
Example
SQL
ababababaocient data warehouse
Example
SQL
ocient
LTRIM
Removes leading blanks from the string valuestring.
Alternatively, you can specify a second string value trim_character. If you specify the trim_character value, the LTRIM function removes all leading instances of the trim_character value from the string.
Syntax
SQL
Example
SQL
ocient
Example
SQL
ocient
Example
In this example, all characters 'abeo ' are removed from the left side of the string.
SQL
cient
MD5
Returns the hexadecimal string (all lowercase) representing the md5 hash ofchar.
Syntax
SQL
SQL
438f03cf6e9ddf8793e02db25f2d2f88
MID
Alias for SUBSTRING.OCTET_LENGTH
Returns the length in bytes of a character or binary value. SyntaxSQL
SQL
1
Example
SQL
6
POSITION
Alias for LOCATE.REGEXP_COUNT
Searches a string for all occurrences of a regular expression pattern. The function returns an integer representing the number of times the regular expression pattern occurs in the string. SyntaxSQL
Example
This example searches the
'ABABDaSGRESaB' string for the count of occurrences of the 'AB' string by ignoring the case sensitivity. The search starts at position 1.
SQL
3
REGEXP_INSTR
Searches a string using a regular expression pattern and returns an integer representing the start position or end position of the substring that matches. The function returns0 if no match is found.
The REGEXP_INSTR function is similar to the POSITION function, but it allows greater precision with regular expressions.
Syntax
SQL
Example
The query searches the website URL for the substring preceded by the
# character. The function includes optional arguments to start the search at position 9 and match the first occurrence. The last specified optional argument directs the function to return the ending position of the matching substring.
SQL
57
REGEXP_REPLACE
Searches a string for all occurrences of a regular expression pattern. The function replaces every match occurrence of the pattern with a new string. TheREGEXP_REPLACE function is similar to the REPLACE and TRANSLATE functions, but it allows greater precision with regular expressions.
Syntax
SQL
Examples
Replace Text Using a Substring
The query replaces the matching substring
'#J28jB' with the characters '#0FqD_'. The search begins at position 9.
SQL
/character-and-binary-functions
Replace Text Using Multiple Capture Groups
This example uses three capture groups to take an unformatted phone number and convert it into the (XXX) XXX-XXXX format. The replace_string argument references each capture group as $1, $2, and $3.
SQL
(555) 867-5309
REGEXP_SUBSTR
Returns one substring from a string that matches a specified regular expression pattern.REGEXP_SUBSTR is similar to the SUBSTR function, but it allows greater precision with regular expressions.
If the pattern produces no matches, the function returns an empty string.
Syntax
SQL
Example
The query returns the first occurrence of the
#J28jB string by using the regular expression pattern '#\w+'. The search starts at position 9.
SQL
#J28jB
REPEAT
Repeats thechar string num times without spaces.
Syntax
SQL
a string five times.
SQL
aaaaa
REPLACE
Replaces all occurrences ofsubstr_to_remove in the character value string with substr_to_replace.
Syntax
SQL
Example
SQL
$c$c$c$c
REVERSE
Reverse the input string. SyntaxSQL
SQL
dcba
RIGHT
Return the number of trailing characters in the string equal to the valueinteger.
Syntax
SQL
Example
SQL
arehouse
Example
SQL
ent data warehouse
RPAD
Pad the input text to the specified length with the pad string on the right side. If text is longer than length, it is truncated tolength characters. If the argument pad is not provided, the space character is used.
Syntax
SQL
Example
SQL
ocient data warehouse
Example
SQL
ocient data warehouseababababa
RSUBSTRING
Returns the substring from the right side of a string, based on a specified length. SyntaxSQL
Example
SQL
data warehouse
RTRIM
Removes trailing blanks from the string valuestring.
Alternatively, you can specify a second string value trim_character. If you specify the trim_character value, the RTRIM function removes all trailing instances of the trim_character value from the string.
Syntax
SQL
Example
SQL
ocient
Example
SQL
ocient
SHA1
Uses the [SHA-1](https://en.wikipedia.org/wiki/SHA-1#:~:text=In%20cryptography%2C%20SHA%2D1%20(,rendered%20as%2040%20hexadecimal%20digits.) cryptographic hash function to convert a string into a 40-character string representing the hexadecimal value of a 160-bit checksum. SyntaxSQL
Example
SQL
0c2a9a042b9f047f875c3414e7a4f4c53efbe082
SPACE
Returns a string of repeated spaces equal to the number value,repeat. You can join this to another string by using the CONCAT function.
Syntax
SQL
SQL
end
SPLIT_PART
Split the valuestring based on the delimiter value. The function returns a substring from the split operation based on the index value (starting from 1).
Syntax
SQL
Example
SQL
id
Example
SQL
name
Example
SQL
address
SPLIT_TO_ARRAY
Splits a string into an array of substrings. SyntaxSQL
Example
This example specifies
| as the delimiter to split the input string.
SQL
['AB','CD','EF']
STARTSWITH
Returnstrue if string starts with substring and false otherwise.
Syntax
SQL
Example
SQL
true
Example
SQL
false
STRPOS
Equivalent to using LOCATE asLOCATE(substring, string). Note the reversed argument order.
Syntax
SQL
Example
SQL
17
SUBSTR
Alias for SUBSTRING.SUBSTRING
Alias for SUBSTR and MID. Returns the substring of a character or binary value that starts with the position specified by the second argument and that ends with the position specified by one less than the sum of the second and third arguments. When the sum of the second and third arguments is less than two, the function returns the empty string. SyntaxSQL
Example
SQL
data warehouse
Example
SQL
data
TO_CHAR
Converts a numeric, date, or timestamp value into aCHAR date type.
SQL
Example
SQL
2020-06-10
Example
SQL
13:25:14
TRANSLATE
Replaces specified characters in a provided string with a separate set of characters. Characters specified in thechar_to_remove set are replaced with characters in the char_to_replace set based on the corresponding index position.
Syntax
SQL
Example
SQL
gbhdif
TRIM
Alias for BTRIM. Trim leading and trailing space characters from the string. Alternatively, you can specify a second string valuetrim_char. If a trim_char value is provided, the TRIM function removes all leading and trailing instances of the trim_char value from the string.
Syntax
SQL
Example
SQL
trimmed string
Example
SQL
trimmed string
UCASE
Alias for UPPER.UPPER
Alias for UCASE. Convert string to upper case. SyntaxSQL
SQL
OCIENT
Concatenate Operator(||)
The || operator concatenates two strings. If you specify a NULL string, the result is NULL.
|| Syntax
SQL
Examples
Concatenate Two Strings
Concatenate two strings.
SQL
'hello world'
Concatenate a NULL String
Concatenate two strings, one of which is NULL.
SQL
NULL

