larf311
larf311

Reputation: 1835

How do you strip leading spaces in Oracle?

I need to strip leading spaces from a column in Oracle. I've Googled but haven't found any answers except to write my own function which I'd like to avoid.

What's the easiest way to accomplish this?

Upvotes: 7

Views: 44893

Answers (4)

Reizorc
Reizorc

Reputation: 1

Update TABLE_NAME set FIELD_NAME = TRIM(COLUMN_NAME)

Upvotes: -1

Jonathan
Jonathan

Reputation: 12015

UPDATE table SET field = TRIM(field);

Upvotes: -1

FerranB
FerranB

Reputation: 36837

You can user LTRIM Oracle function:

SQL> select ltrim(' hello world') from dual;

LTRIM('HELLOWORLD')
-------------------
hello world

For ending spaces you can use RTRIM. And for more options check out TRIM.

Upvotes: 20

joe
joe

Reputation: 35117

use the trim function removes all specified characters either from the beginning or the ending of a string.

trim( [ leading | trailing | both  [ trim_character ]  ]   string1 )

Upvotes: 3

Related Questions