String functions

String functions work on values of a text column.

CHARACTER_LENGTH

Supported datatypes: VARCHAR

A synonym for CHAR_LENGTH.

Example

SELECT CHARACTER_LENGTH(<col_1>)
FROM <table_name>

CHAR_LENGTH

Supported datatypes: VARCHAR

Obtain the count of characters of the string for each row of a text column.

Example

SELECT CHAR_LENGTH(<col_1>)
FROM <table_name>

CONCAT

Supported datatypes: VARCHAR

Obtain a string that is a concatenation of two or more text columns or literals.

Warning

This function returns NULL if any of the elements is NULL.

Examples

Concatenating two text columns.

SELECT CONCAT(<col_1>, <col_2>)
FROM <table_name>

Concatenating two columns with an additional delimiter between.

SELECT CONCAT(<col_1>, '_', <col_2>)
FROM <table_name>

INITCAP

Supported datatypes: VARCHAR

Obtain a string with every word capitalized.

See also

LOWER, UPPER

Example

SELECT INITCAP(<col_1>)
FROM <table_name>

LOWER

Supported datatypes: VARCHAR

Obtain a string with every character converted to lower caps.

See also

INITCAP, UPPER

Example

SELECT LOWER(<col_1>)
FROM <table_name>

UPPER

Supported datatypes: VARCHAR

Obtain a string with every character converted to upper caps.

See also

INITCAP, LOWER

Example

SELECT UPPER(<col_1>)
FROM <table_name>

LEFT

Supported datatypes: VARCHAR

Obtain a substring of a string with a specified number of leftmost characters.

See also

RIGHT, SUBSTRING

Example

Retrieve first 3 characters from a string.

SELECT LEFT(<col_1>, 3)
FROM <table_name>

SUBSTRING

Supported datatypes: VARCHAR

Obtain a substring of a string with a specified number of characters starting at a specified position.

See also

LEFT, RIGHT

Example

Retrieve 3 characters from a string starting at position 4.

SELECT SUBSTRING(<col_1>, 4, 3)
FROM <table_name>

LTRIM

Supported datatypes: VARCHAR

Obtain a string with all leading whitespace characters removed.

See also

RTRIM, TRIM

Example

SELECT LTRIM(<col_1>)
FROM <table_name>

RTRIM

Supported datatypes: VARCHAR

Obtain a string with all trailing whitespace characters removed.

See also

LTRIM, TRIM

Example

SELECT RTRIM(<col_1>)
FROM <table_name>

TRIM

Supported datatypes: VARCHAR

Obtain a string with all leading and trailing whitespace characters removed.

See also

LTRIM, RTRIM

Example

SELECT TRIM(<col_1>)
FROM <table_name>

REGEXP_REPLACE

Supported datatypes: VARCHAR

Obtain a string with all instances of a Regex pattern are replaced with a specified replacement.

Note

The regular expressions pattern rules apply when specifying the pattern. For example, to replace a backslash character \ it needs to be escaped resulting in the \\ pattern.

See also

REPLACE

Example

SELECT REGEXP_REPLACE(<col_1>, <pattern>, <replacement>)
FROM <table_name>

REPLACE

Supported datatypes: VARCHAR

Obtain a string with all instances of a match substring are replaced with a specified replacement.

See also

REGEXP_REPLACE

Example

SELECT REPLACE(<col_1>, <substring>, <replacement>)
FROM <table_name>

REVERSE

Supported datatypes: VARCHAR

Obtain a string with all characters in reverse order.

Example

SELECT REVERSE(<col_1>)
FROM <table_name>