String functions
String functions perform conversion, extraction, or manipulation operations on strings, or return information about strings.
This section describes functions and operators for examining and manipulating string values. Strings in this context include values of the types CHAR, VARCHAR, BINARY, and VARBINARY.
Unless otherwise noted, all of the functions listed in this section work on all four data types. As opposed to some other SQL implementations, Vertica keeps CHAR strings unpadded internally, padding them only on final output. So converting a CHAR(3) 'ab' to VARCHAR(5) results in a VARCHAR of length 2, not one with length 3 including a trailing space.
Some of the functions described here also work on data of non-string types by converting that data to a string representation first. Some functions work only on character strings, while others work only on binary strings. Many work for both. BINARY and VARBINARY functions ignore multibyte UTF-8 character boundaries.
Non-binary character string functions handle normalized multibyte UTF-8 characters, as specified by the Unicode Consortium. Unless otherwise specified, those character string functions for which it matters can optionally specify whether VARCHAR arguments should be interpreted as octet (byte) sequences, or as (locale-aware) sequences of UTF-8 characters. This is accomplished by adding "USING OCTETS" or "USING CHARACTERS" (default) as a parameter to the function.
Some character string functions are stable because in general UTF-8 case-conversion, searching and sorting can be locale dependent. Thus, LOWER is stable, while LOWERB is immutable. The USING OCTETS clause converts these functions into their "B" forms, so they become immutable. If the locale is set to collation=binary, which is the default, all string functions—except CHAR_LENGTH/CHARACTER_LENGTH, LENGTH, SUBSTR, and OVERLAY—are converted to their "B" forms and so are immutable.
BINARY implicitly converts to VARBINARY, so functions that take VARBINARY arguments work with BINARY.
In this section
- ASCII
- BIT_LENGTH
- BITCOUNT
- BITSTRING_TO_BINARY
- BTRIM
- CHARACTER_LENGTH
- CHR
- COLLATION
- CONCAT
- DECODE
- EDIT_DISTANCE
- GREATEST
- GREATESTB
- HEX_TO_BINARY
- HEX_TO_INTEGER
- INITCAP
- INITCAPB
- INSERT
- INSTR
- INSTRB
- ISUTF8
- LEAST
- LEASTB
- LEFT
- LENGTH
- LOWER
- LOWERB
- LPAD
- LTRIM
- MAKEUTF8
- MD5
- OCTET_LENGTH
- OVERLAY
- OVERLAYB
- POSITION
- POSITIONB
- QUOTE_IDENT
- QUOTE_LITERAL
- QUOTE_NULLABLE
- REPEAT
- REPLACE
- RIGHT
- RPAD
- RTRIM
- SHA1
- SHA224
- SHA256
- SHA384
- SHA512
- SOUNDEX
- SOUNDEX_MATCHES
- SPACE
- SPLIT_PART
- SPLIT_PARTB
- STRPOS
- STRPOSB
- SUBSTR
- SUBSTRB
- SUBSTRING
- TRANSLATE
- TRIM
- UPPER
- UPPERB