Sqlite Rtrim Function

SQLite: rtrim Function

This SQLite post explains how to use the SQLite rtrim function with syntax and examples.

Description

The SQLite rtrim function removes all specified characters from the right-hand side of a string.

Syntax

The syntax for the rtrim function in SQLite is:

rtrim( string, [ trim_string ] )

Parameters or Arguments

string

The string to trim the characters from the right-hand side.

trim_string

The string that will be removed from the right-hand side of string. If this parameter is omitted, the rtrim function will remove all trailing spaces from string.

Note

Applies To

The rtrim function can be used in the following versions of SQLite:

  • SQLite 3.8.6, SQLite 3.8.x, SQLite 3.7.x, SQLite 3.6.x

Example

Let's look at some SQLite rtrim function examples and explore how to use the rtrim function in SQLite.

For example:

sqlite> SELECT rtrim('AODBA.com   ');
Output: 'AODBA.com'

sqlite> SELECT rtrim('   AODBA.com   ');
Output: '   AODBA.com'

sqlite> SELECT rtrim('AODBA.com    is great!   ');
Output: 'AODBA.com    is great!'

sqlite> SELECT rtrim('123000', '0');
Output: '123'

sqlite> SELECT rtrim('dbd123123', '123');
Output: 'dbd'

sqlite> SELECT rtrim('123dbd123123', '123');
Output: '123dbd'



sqlite> SELECT rtrim('dbd6372', '0123456789');
Output: 'dbd'