SQL 你如何去除 Oracle 中的前导空格?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1119456/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 02:46:34  来源:igfitidea点击:

How do you strip leading spaces in Oracle?

sqloracle

提问by larf311

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.

我需要从 Oracle 中的列中去除前导空格。我已经谷歌搜索但没有找到任何答案,除了编写我自己想要避免的函数。

What's the easiest way to accomplish this?

实现这一目标的最简单方法是什么?

回答by FerranB

You can user LTRIMOracle function:

您可以使用LTRIMOracle 函数:

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.

对于结束空格,您可以使用RTRIM。有关更多选项,请查看TRIM

回答by joe

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

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

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

回答by Jonathan

UPDATE table SET field = TRIM(field);

更新表 SET 字段 = TRIM(field);

回答by Reizorc

Update TABLE_NAME set FIELD_NAME = TRIM(COLUMN_NAME)

更新 TABLE_NAME 集 FIELD_NAME = TRIM(COLUMN_NAME)