String functions
String functions are built-in tools used to manipulate and process text data. They enable tasks like concatenation, extraction, formatting, and searching within strings. These functions are essential for cleaning, transforming, and analyzing text-based data within a database.
Function |
Signature |
Description |
---|---|---|
|
LENGTH (string) |
Returns the length of the string. |
|
CONCAT (string, string) |
Concatenates arguments in a string. |
|
|
Returns one of the following:
Uses 1-based indexing for start parameter. |
|
UPPER (string) |
Converts the characters in the input string to uppercase. |
|
LOWER (string) |
Converts the characters in the input string to lowercase. |
|
TRIM (string) |
Removes any space characters from the beginning, end, or both sides of string. |
|
LTRIM (string) |
Removes any space characters from the beginning of string. |
|
RTRIM (string) |
Removes any space characters from the end of string. |
|
STR_REPLACE (string, from, to) |
Replaces all occurrences of the specified substring with another specified substring. |
Examples of all the functions:
Function |
Example |
---|---|
LENGTH |
|
CONCAT |
|
SUBSTR |
|
UPPER |
|
LOWER |
|
TRIM |
|
LTRIM |
|
RTRIM |
|
STR_REPLACE |
|
Concatenation operator
The concatenation operator ||
, or pipe operator, joins two strings together. It
provides an alternative to the CONCAT
function, and is more readable when combining
multiple strings.
Example of the concatenation operator
SELECT a.asset_name || ' - ' || p.property_name AS full_name FROM asset a, asset_property p