Skip to content

BTRIM

BTRIM(string text [, trim_string text]) RETURNS text

Section titled “BTRIM(string text [, trim_string text]) RETURNS text”
  • string text: This is the primary input string from which the leading and trailing spaces or characters will be removed. The function processes this parameter to identify and eliminate excess spaces or defined characters at both ends of the input string.
  • trim_string text: This is an optional parameter. If provided, the function removes any characters that match with any characters in the trim_string from the beginning or end of the string text. When not provided, the function defaults to removing leading and trailing spaces.
SELECT BTRIM(' PostgreSQL ');
"PostgreSQL"

The BTRIM function in SQL is used to remove the leading and trailing spaces from the string. In the provided example, the string ’ PostgreSQL ’ has spaces at the beginning and the end. After applying BTRIM, these spaces are removed and we are left with the trimmed output “PostgreSQL”.