SQLite rtrim() function

SQLite rtrim() function removes trailing spaces or specified characters from a string. It returns a new copy of the input string with the trailing characters removed.

Syntax

rtrim(string,[character])Code language: SQL (Structured Query Language) (sql)

Arguments

The rtrim() function accepts two arguments:

string

The input string that you want to remove the characters.

character

The character string that you want to remove from the input string. It is optional.

If you don’t specify it, it is assumed to be a space character and the  rtrim() function will remove all trailing space from the input string.

If you explicitly specify the characters you want to remove, the rtrim() function will remove all the specified characters at the end of the string.

Return Type

TEXT

Examples

The following statement uses the rtrim() function to remove trailing spaces from a string:

SELECT rtrim('SQLite   ') result;Code language: SQL (Structured Query Language) (sql)

Output:

result
------
SQLite

The following statement uses the rtrim() function to the USD from an amount:

SELECT rtrim('500USD', 'USD') amount;Code language: SQL (Structured Query Language) (sql)

Output:

amount
------
500

See Also

trimltrim

Was this tutorial helpful ?