Detailed explanation of the method of removing carriage return and line feed space in oracle

  • 2021-07-06 12:00:28
  • OfStack

Strip line breaks
update zhzl_address t set t.add_administration_num=replace(t.add_administration_num,chr(10),'');
Remove carriage return
update zhzl_address t set t.add_administration_num=replace(t.add_administration_num,chr(13),'');
Remove spaces
update zhzl_address t set t.add_administration_num=trim(t.add_administration_num);
-----------------------------
1. Enter line feeds
chr (10) is a line break,
chr (13) is carriage return,
Add line breaks
select ' update ' || table_name ||
' set VALID_STATE =''0A'';'||chr(13)||' commit;'
from user_tables

Delete line breaks
select id,replace(content,to_char(chr(13))||to_char(chr(10)),'_r_n') from fact_content order by content;

In oracle, line breaks, carriage returns and tab summaries are removed from the text
1. Definition of special symbol ascii
Tab Character chr (9)
Line break chr (10)
Enter chr (13)
2. Use repalce for nesting. Note that only one symbol can be submitted at a time, such as carriage return before line break
select REPLACE(gg, chr(10), '') from dual
Note that chr (13) chr (10) is used in combination, and carriage return and line feed are better in notepad, so we should consider this situation
select translate(string,chr(13)||chr(10),',') from dual;

3. Symbolic processing of large character objects
For symbol processing in the clob field, to_char is followed by sample 1 processing
SQL > select to_char(vcl),replace(to_char(vcl),chr(10),'[]') from test_1;

Related articles: