QuestDB provides comprehensive string manipulation functions supporting STRING, VARCHAR, and SYMBOL types.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/questdb/questdb/llms.txt
Use this file to discover all available pages before exploring further.
Concatenation
concat
Concatenates multiple values into a string. Signature:concat(V)
Parameters:
V- Variable arguments of any type
STRING
Example:
- Accepts any type - numbers, timestamps, etc. are converted to strings
- NULL values are ignored (not concatenated)
- Constant expressions are optimized at compile time
|| operator
Concatenation operator. Example:Length Functions
length
Returns character length of string. Signature:length(S)
Parameters:
S- STRING, VARCHAR, or SYMBOL
INT
Example:
length_bytes
Returns byte length of string (UTF-8 encoding). Signature:length_bytes(S)
Parameters:
S- STRING or VARCHAR
INT
Example:
Case Conversion
upper
Converts string to uppercase. Signature:upper(S)
Parameters:
S- STRING, VARCHAR, or SYMBOL
lower
Converts string to lowercase. Signature:lower(S)
Parameters:
S- STRING, VARCHAR, or SYMBOL
Substring Functions
substring
Extracts substring from string. Signature:substring(SII) or substr(SII)
Parameters:
S- STRING, VARCHAR, or SYMBOL- First
I- Start position (1-based) - Second
I- Length
left
Extracts leftmost characters. Signature:left(SI)
Parameters:
S- STRING, VARCHAR, or SYMBOLI- Number of characters
right
Extracts rightmost characters. Signature:right(SI)
Parameters:
S- STRING, VARCHAR, or SYMBOLI- Number of characters
Search Functions
strpos
Finds position of substring (1-based, 0 if not found). Signature:strpos(SS)
Parameters:
- First
S- String to search in - Second
S- Substring to find
INT
Example:
position
Alias forstrpos().
Signature: position(SS)
Parameters:
- First
S- String to search in - Second
S- Substring to find
INT
Pattern Matching
starts_with
Checks if string starts with prefix. Signature:starts_with(SS)
Parameters:
- First
S- String to check - Second
S- Prefix
BOOLEAN
Example:
LIKE operator
Pattern matching with wildcards. Example:~ operator
Regular expression matching. Example:Trimming Functions
trim
Removes leading and trailing whitespace. Signature:trim(S)
Parameters:
S- STRING or VARCHAR
ltrim
Removes leading whitespace. Signature:ltrim(S)
Parameters:
S- STRING or VARCHAR
rtrim
Removes trailing whitespace. Signature:rtrim(S)
Parameters:
S- STRING or VARCHAR
Padding Functions
lpad
Pads string on left to specified length. Signature:lpad(SIS) or lpad(SI)
Parameters:
- First
S- String to pad I- Target length- Second
S- Padding character (optional, defaults to space)
rpad
Pads string on right to specified length. Signature:rpad(SIS) or rpad(SI)
Parameters:
- First
S- String to pad I- Target length- Second
S- Padding character (optional, defaults to space)
Replace Functions
replace
Replaces all occurrences of substring. Signature:replace(SSS)
Parameters:
- First
S- Source string - Second
S- Substring to find - Third
S- Replacement string
Splitting Functions
split_part
Extracts field from delimited string. Signature:split_part(SSI)
Parameters:
- First
S- String to split - Second
S- Delimiter I- Field number (1-based)
Hashing Functions
md5
Computes MD5 hash. Signature:md5(S)
Parameters:
S- STRING, VARCHAR, or BINARY
STRING (hex)
Example:
sha1
Computes SHA-1 hash. Signature:sha1(S)
Parameters:
S- STRING, VARCHAR, or BINARY
STRING (hex)
Example:
sha256
Computes SHA-256 hash. Signature:sha256(S)
Parameters:
S- STRING, VARCHAR, or BINARY
STRING (hex)
Example:
Type Conversion
to_char
Converts value to string. Signature:to_char(V)
Parameters:
V- Any value
STRING
Example:
Utility Functions
quote_ident
Quotes identifier for SQL. Signature:quote_ident(S)
Parameters:
S- STRING or VARCHAR
STRING
Example:
size_pretty
Formats byte size in human-readable format. Signature:size_pretty(L)
Parameters:
L- LONG (bytes)
STRING
Example:
String Aggregation
See Aggregation Functions for:string_agg()- Concatenate strings with separatorstring_distinct_agg()- Concatenate unique strings
Performance Notes
String Types
- SYMBOL: Internalized strings, best for repeated values
- STRING: Variable-length UTF-16 strings
- VARCHAR: Variable-length UTF-8 strings
Optimization
- String functions avoid allocations where possible
- Constant expressions are evaluated at compile time
- Use SYMBOL type for frequently repeated strings
NULL Handling
Most string functions return NULL if any argument is NULL. Exceptions:concat()ignores NULL values- Length functions return NULL for NULL input