Jump to: navigation, search

PostgreSQL TRIM

From w3cyberlearnings

Contents

Postgresql trim

By default it is removed the white space. If specific a character, it will remove the character from the string. This function is used to remove white space or specific characters for both size (left and right), left only, or right only.

Syntax trim

  • remove: the option can be leading, trailing or both.
  • string: sets the string or character to removed
  • mainstring: is the main string to remove a white space or specific character set by the remove argument.
trim(remove string from mainstring)

Example 1

test2=# SELECT trim(both '$' from '$kive$');
 btrim 
-------
 kive
(1 row)

Example 2

test2=# SELECT trim(trailing '$' from '$kive$');
 rtrim 
-------
 $kive
(1 row)

Example 3

test2=# SELECT trim(leading '$' from '$kive$');
 ltrim 
-------
 kive$
(1 row)

Related Links


Navigation
Web
SQL
MISC
References