ltrim Function

The ltrim function enables you to trim leading characters from a string.

Syntax

returnvalue ltrim(source)

source ::= any*
returnvalue ::= string

Semantics

source

The input string that should be trimmed. The leading spaces in this string are removed. This argument is implicitly cast to a sequence of strings.

returnvalue

Returns NULL if the source argument is NULL.

Returns NULL if the source argument is an empty sequence or a sequence with more than one item.

Example 12-12 trim Function

This example demonstrates ltrim function. Notice that the empty spaces at the beginning are removed but the empty spaces at the end are not removed.

Note:

You can use JSON query output mode so that the empty spaces are visible.
MODE JSON

SELECT id, ltrim(name) FROM trim_demo;
{"id":10,"Column_2":"Peter  "}
{"id":20,"Column_2":"Mary"}
{"id":30,"Column_2":"Oliver"}
{"id":40,"Column_2":"John  "}