PostgreSQL LTRIM Function

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PostgreSQL LTRIM() function

LTRIM() function

The PostgreSQL ltrim() function is used to remove spaces ( if no character(s) is provided as trimming_text ) or set of characters which are matching with the trimming_text, from the start of a string.

Syntax :

ltrim(<string>[, <triming_text>]) 

PostgreSQL Version : 9.3

Pictorial Presentation of PostgreSQL LTRIM() function

 

Example : PostgreSQL ltrim() function :

In the example below, the statement returns the result 'ltrim'. Here in the example the trimming_text is provided, and it is 'best', and the left four characters i.e. 'test' have removed and the characters 't' and 'e' and 's' are present in the trimming_text 'best'.

SELECT ltrim('testltrim', 'best');

Output :

 ltrim
-------
 ltrim
(1 row)

Example of PostgreSQL ltrim() function with no text :

In the example below, the trimming_text is not provided, so by default the white spaces from the left side of the given string will be removed.

SELECT ltrim('     ltrim');

Output :

 ltrim
-------
 ltrim
(1 row)