Skip to content

BTRIM

Remove leading or trailing characters based on a specified list. By default, remove leading and trailing spaces.

BTRIM(string [ ,string ])
premdb=# SELECT BTRIM(' Bob ');
 btrim 
-------
 Bob
(1 row)

premdb=# SELECT BTRIM(' Bob ','Bb');
 btrim 
-------
  Bob 
(1 row)

premdb=# SELECT BTRIM(' Bob ','Bb ');
 btrim 
-------
 o
(1 row)

This example removes the trailing lowercase s from the nickname column:

premdb=# SELECT nickname, BTRIM(nickname,'s') FROM team;
  nickname  |   btrim   
------------+-----------
 Gunners    | Gunner
 Villains   | Villain
 Tykes      | Tyke
 Blues      | Blue
 Rovers     | Rover
 Seasiders  | Seasider
 Trotters   | Trotter
 Cherries   | Cherrie
...

Parent topic:String Functions