目前,在测试表的地址列中,我有以下格式的数据:
12th street
Test avenue
Test_City
但是在输出结果中,我需要它按照以下格式显示:
12th street Test avenue Test_City。
请问有谁能告诉我使用的查询以按所需方式显示它。
你可以尝试这个:
select regexp_replace(your_address,'[[:space:]]',' ') from your_tab;
select regexp_replace('12th street Test avenue Test_City','[[:space:]]', ' ') from dual
得到 12th street Test avenue Test_City
。 - Cyryl1972[[:space:]]
改成 [[:space]]+
或者更简单的 \s+
,这样多个换行符(例如)就会被替换为一个空格。 - David Faber只需从字符串中删除chr(13)和chr(10):
declare
teststring varchar2 (32767) := ' This is the value
that I chose';
begin
dbms_output.put_line (teststring);
dbms_output.put_line (replace (replace (teststring, chr (13), ''), chr (10), ' '));
end;
This is the value
that I chose
This is the value that I chose
我在文本中放入两个回车,因此需要两个空格。
试试这个:
translate(' example ', chr(10) || chr(13) || chr(09), ' ')
select trim(chr(13) FROM trim(chr(10) FROM your_column)) from your_table
select replace(address, chr(10), ' ') from customer
,但是你的问题有点不清楚... - Erich Kitzmueller