首页 » ORACLE 9i-23c » oracle sql 清除值中的空格

oracle sql 清除值中的空格

常常在表中有用户从页面填写的信息,上传到数据库中存在空格,为以后判断带个麻烦,今天谈论怎么去除空格.

SQL> select ‘begin’|| ‘   abcd  efg   ‘||’end’ rt from dual;
RT
———————————————-
begin   abcd  efg   end
SQL> select ‘begin’|| ltrim(‘   abcd  efg   ‘)||’end’ rt from dual;
RT
—————————————-
beginabcd  efg   end
SQL> select ‘begin’|| rtrim(‘   abcd  efg   ‘)||’end’ rt from dual;
RT
—————————————-
begin   abcd  efgend
SQL> select ‘begin’|| trim(‘   abcd  efg   ‘)||’end’ rt from dual;
RT
———————————-
beginabcd  efgend
SQL> select ‘begin’|| replace(‘   abcd  efg   ‘,’ ‘,”)||’end’ rt from dual;
RT
——————————
beginabcdefgend
SQL> select ‘begin’|| regexp_replace(‘   abcd  efg   ‘,'( ){1,}’,”)||’end’ rt from dual;
RT
——————————
beginabcdefgend
SQL>

如果更新表 最好还是加个where 条件再更新会快些

1,where col like ‘% %’ –中间有空格;

2,   where   instr(name,chr(32))>0

打赏

目前这篇文章有2条评论(Rss)评论关闭。

  1. Geraldo Pedeare | #1
    2011-12-21 at 06:59

    I got what you mean , thanks for putting up.

  2. webcam girls | #2
    2011-11-26 at 20:15

    Awesome information. Thanks a lot for the useful info!By the way, I am having difficulties with subscribing to your RSS feed, could you help me with the subscribing process? Anyway, awaiting another awesome post!