TRIM function in Amazon QLDB
Important
End of support notice: Existing customers will be able to use Amazon QLDB until end of support on 07/31/2025. For more details, see
Migrate an Amazon QLDB Ledger to Amazon Aurora PostgreSQL
In Amazon QLDB, use the TRIM
function to trim a given string by removing
the leading and trailing blank spaces or a specified set of
characters.
Syntax
TRIM ( [ LEADING | TRAILING | BOTH [
characters
] FROM ]string
)
Arguments
- LEADING
-
(Optional) Indicates that the blank spaces or specified characters are to be removed from the beginning of
string
. If not specified, the default behavior isBOTH
. - TRAILING
-
(Optional) Indicates that the blank spaces or specified characters are to be removed from the end of
string
. If not specified, the default behavior isBOTH
. - BOTH
-
(Optional) Indicates that both the leading and trailing blank spaces or specified characters are to be removed from the beginning and end of
string
. characters
-
(Optional) The set of characters to remove, specified as a
string
.If this parameter is not provided, blank spaces are removed.
string
-
The field name or expression of data type
string
that the functions trims.
Return type
string
Examples
TRIM(' foobar ') -- 'foobar' TRIM(' \tfoobar\t ') -- '\tfoobar\t' TRIM(LEADING FROM ' foobar ') -- 'foobar ' TRIM(TRAILING FROM ' foobar ') -- ' foobar' TRIM(BOTH FROM ' foobar ') -- 'foobar' TRIM(BOTH '1' FROM '11foobar11') -- 'foobar' TRIM(BOTH '12' FROM '1112211foobar22211122') -- 'foobar' -- Runnable statements SELECT TRIM(' foobar ') FROM << 0 >> -- "foobar" SELECT TRIM(LEADING FROM ' foobar ') FROM << 0 >> -- "foobar "