To remove spaces from the left side of a string use the ltrim()
function in Oracle SQL.
LTRIM() Syntax
ltrim(string, set)
The LTRIM() function deletes all the characters in set
from the left end of the string. If set
is not given, a single blank will be used.
Removing Spaces from Left of a String in Oracle SQL
The following Oracle SQL query removes the spaces from the left side of the string:
select ltrim(' this is the string.') from dual
Output:
this is a string.
To remove the specific characters from the left side of a string, check the below example:
select ltrim('**this is the string.', '*') from dual
Output:
this is the string.
Using LTRIM() Function in PL/SQL
The following PL/SQL program removes the space from the left side of a string and prints on the screen:
declare v_string varchar2(100) := ' Oracle SQL'; begin dbms_output.put_line(ltrim(v_string)); end;
Output:
Oracle SQL
See also:
- Add Leading Characters to a String in Oracle SQL
- Convert to Lowercase in Oracle SQL
- Replace Multiple Characters in a String in Oracle?
- Remove Spaces from Right in Oracle