Skip to main content
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.
Syntax
SQL
Example
SQL
*Output: *97 Example
SQL
*Output: *98

BIT_LENGTH

Returns the length of the character value in bits. Syntax
SQL
Example
SQL
*Output: *8 Example
SQL
*Output: *16 Example
SQL
*Output: *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. Syntax
SQL
Example
SQL
*Output: *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. Syntax
SQL
Example
SQL
*Output: *ocient data warehouse Example
SQL
*Output: *ocient data warehouse

ENDSWITH

Returns true if x ends with y and false otherwise. Syntax
SQL
Example
SQL
*Output: *true Example
SQL
*Output: *false Example
SQL
*Output: *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. Syntaxes
SQL

INSTR

Returns the index position of the first occurrence where the character value char_substring appears in the character value char by ignoring the case. Syntax
SQL
Example
SQL
*Output: *1
SQL
*Output: *8

JSON_EXTRACT_PATH_TEXT

Returns the value for the key-value pair referenced by a series of path elements in a JSON string. Syntax
SQL
Examples Extract Values from Nested Paths This example extracts the value based on two specified paths in the JSON string, n4 and n6.
SQL
*Output: *"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
*Output: *NULL

LCASE

Alias for LOWER.

LEFT

Return the number of characters in the string equal of the value integer. If integer is negative, the function returns all but the last integer characters. Syntax
SQL
Example
SQL
*Output: *ocient d Example
SQL
*Output: *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. Syntax
SQL
Example
SQL
*Output: *21

LOCATE

Alias for POSITION. Returns the index position of the first occurrence of the character value substring 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
*Output: *13 Example
SQL
*Output: *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
*Output: *15

LOWER

Alias for LCASE. Convert string to lowercase. Syntax
SQL
Example
SQL
*Output: *ocient Example
SQL
*Output: *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 to length characters. If the argument pad is not provided, the space character is used. Syntax
SQL
Example
SQL
*Output: *ababababaocient data warehouse Example
SQL
*Output: *ocient

LTRIM

Removes leading blanks from the string value string. 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
*Output: *ocient Example
SQL
*Output: *ocient Example In this example, all characters 'abeo ' are removed from the left side of the string.
SQL
*Output: *cient

MD5

Returns the hexadecimal string (all lowercase) representing the md5 hash of char. Syntax
SQL
Example
SQL
*Output: *438f03cf6e9ddf8793e02db25f2d2f88

MID

Alias for SUBSTRING.

OCTET_LENGTH

Returns the length in bytes of a character or binary value. Syntax
SQL
Example
SQL
*Output: *1 Example
SQL
*Output: *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. Syntax
SQL
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
*Output: *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 returns 0 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
*Output: *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. The REGEXP_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
*Output: */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
*Output: *(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
*Output: *#J28jB

REPEAT

Repeats the char string num times without spaces. Syntax
SQL
Example Repeat the a string five times.
SQL
*Output: *aaaaa

REPLACE

Replaces all occurrences of substr_to_remove in the character value string with substr_to_replace. Syntax
SQL
Example
SQL
*Output: *$c$c$c$c

REVERSE

Reverse the input string. Syntax
SQL
Example
SQL
*Output: *dcba Return the number of trailing characters in the string equal to the value integer. Syntax
SQL
Example
SQL
*Output: *arehouse Example
SQL
*Output: *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 to length characters. If the argument pad is not provided, the space character is used. Syntax
SQL
Example
SQL
*Output: *ocient data warehouse Example
SQL
*Output: *ocient data warehouseababababa

RSUBSTRING

Returns the substring from the right side of a string, based on a specified length. Syntax
SQL
Example
SQL
*Output: *data warehouse

RTRIM

Removes trailing blanks from the string value string. 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
*Output: *ocient Example
SQL
*Output: *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. Syntax
SQL
Example
SQL
*Output: *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
Example
SQL
*Output: * end

SPLIT_PART

Split the value string 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
*Output: *id Example
SQL
*Output: *name Example
SQL
*Output: *address

SPLIT_TO_ARRAY

Splits a string into an array of substrings. Syntax
SQL
Example This example specifies | as the delimiter to split the input string.
SQL
*Output: *['AB','CD','EF']

STARTSWITH

Returns true if string starts with substring and false otherwise. Syntax
SQL
Example
SQL
*Output: *true Example
SQL
*Output: *false

STRPOS

Equivalent to using LOCATE as LOCATE(substring, string). Note the reversed argument order. Syntax
SQL
Example
SQL
*Output: *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. Syntax
SQL
Example
SQL
*Output: *data warehouse Example
SQL
*Output: *data

TO_CHAR

Converts a numeric, date, or timestamp value into a CHAR date type.
SQL
Example
SQL
*Output: *2020-06-10 Example
SQL
*Output: *13:25:14

TRANSLATE

Replaces specified characters in a provided string with a separate set of characters. Characters specified in the char_to_remove set are replaced with characters in the char_to_replace set based on the corresponding index position. Syntax
SQL
Example
SQL
*Output: *gbhdif

TRIM

Alias for BTRIM. Trim leading and trailing space characters from the string. Alternatively, you can specify a second string value trim_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
*Output: *trimmed string Example
SQL
*Output: *trimmed string

UCASE

Alias for UPPER.

UPPER

Alias for UCASE. Convert string to upper case. Syntax
SQL
Example
SQL
*Output: *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
Output: 'hello world' Concatenate a NULL String Concatenate two strings, one of which is NULL.
SQL
Output: NULL WHERE Formatting Functions
Last modified on June 24, 2026