简体   繁体   中英

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?

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 .

使用trim函数从字符串的开头或结尾删除所有指定的字符。

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

UPDATE表SET字段= TRIM(字段);

更新TABLE_NAME设置FIELD_NAME = TRIM(COLUMN_NAME)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM