SQL 如何从 Oracle 中的 varchar 中删除空格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24007375/
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
How to remove spaces from varchar in Oracle
提问by Denis_Sh
I need to remove all spaces from column values of varchar2 type in an Oracle table.
For example, 2012_2 psk
should become 2012_2psk
.
我需要从 Oracle 表中 varchar2 类型的列值中删除所有空格。例如,2012_2 psk
应该变成2012_2psk
.
I've tried to use REPLACE(column_name, ' ', '')
but it doesn't work.
Can anyone help me?
我试过了,use REPLACE(column_name, ' ', '')
但没有用。
谁能帮我?
回答by Denis_Sh
I've found the solution. There are not white spaces, there are some other symbols that show themselves as blank spaces. So next code is working fine:
我找到了解决方案。没有空格,还有一些其他符号将自己显示为空格。所以下一个代码工作正常:
SELECT regexp_replace(docnum, '\W','') FROM tmp_uploadtable;