<<<<<<< HEAD rtrim | H2 | SQLDoc
Skip to main content

rtrim

1. RTRIM Function

======= rtrim | H2 Function | SQLDoc

rtrim

1. RTRIM Function

>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62be

The RTRIM function in H2 database is used to remove trailing spaces from a string.

2. Syntax

The syntax for the RTRIM function in H2 database is as follows:

RTRIM(string)

Argument

  • string: The string from which trailing spaces need to be removed.

Return

  • The RTRIM function returns the input string with trailing spaces removed.

3. Notes

  • The RTRIM function in H2 database only removes trailing spaces and does not affect leading or inner spaces within the string.
  • If the input string is NULL, the RTRIM function will return NULL.

4. Examples

Here are a few examples demonstrating the usage of the RTRIM function in H2 database:

Example 1 - Removing trailing spaces from a string:

SELECT RTRIM('Hello     ') AS trimmed_string;

Output:

trimmed_string
--------------
Hello

Example 2 - Removing trailing spaces from a column:

CREATE TABLE names (
id INT PRIMARY KEY,
name VARCHAR(50)
);

INSERT INTO names VALUES (1, 'John '), (2, 'Alice '), (3, 'Bob');

SELECT id, RTRIM(name) AS trimmed_name
FROM names;

Output:

id | trimmed_name
---+--------------
1 | John
2 | Alice
3 | Bob
  • ltrim - Remove leading spaces from a string
  • trim - Remove leading and trailing spaces from a string