PostgreSQL BTRIM() function
BTRIM() function
The PostgreSQL btrim function is used to remove the longest string specified in the argument from the start and end of the given string. If no string for removing default space will be removed from leading and trailing side from the string.
Syntax:
btrim(<string>[ , <text_trim>])
PostgreSQL Version: 9.3
Pictorial Presentation of PostgreSQL BTRIM() function

Example - 1: PostgreSQL BTRIM() function:
In the example below, the btrim searches the letters 't' or 'e' or 's' or 't' from the left or right most position of the given string and removes those letters which match consecutively and displays the result 'w3resourc'.
Example:
Code:
SELECT btrim('settw3resourcesttes', 'test');
Sample Output:
btrim ----------- w3resourc (1 row)
Example - 2: PostgreSQL BTRIM() function:
In the example below, the btrim searches the letters white space ( ' ' ) in the given string and removes all white spaces from both sides of the given string.
Example:
Code:
SELECT btrim(' w3resource.com ');
Sample Output:
btrim ---------------- w3resource.com (1 row)
Example - 3: PostgreSQL BTRIM() function:
In the example below, no trimming text have been defined, so this statement by default will remove all white spaces from both sides of the given string.
Example:
Code:
SELECT btrim(' w3resource.com ');
Sample Output:
btrim ---------------- w3resource.com (1 row)
Previous: ASCII function
Next: CHR function
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook