2017-08-29 166 views
1

我使用的是Oracle 11g DB,并且在具有varchar列的表中有一个具有尾随空格的数据。我试过TRIM函数来更新列,但字符串末尾的空格仍然存在。尾随空间的原因是什么?以及如何解决这个问题。不能TRIM在oracle的varchar列中尾随空格

列内容显示如下。

select '<'||mycol||'>' from mytab 
Output : <mysamplestring > 

select DUMP(mycol) from mytab 
Output : Typ=1 Len=28: 67,114,117,100,101,32,80,101,116,114,111,108,101,117,109,32,69,120,116,114,97,99,116,105,111,110,194,160 

感谢

+2

修剪应该工作。显示真正的查询。 – wolfrevokcats

+0

更新我使用的查询:更新mytab设置mycol = TRIM(mycol); –

+2

用'select'<'|| your_coloumn ||'>''或'DUMP(your_column)'尝试查看完整内容 –

回答

0
()应该按预期工作

装饰!确定它是varchar2列而不是char列?

update hr.countries t 
set t.country_name = t.country_name || ' '; 

update hr.countries t 
set t.country_name = trim(t.country_name); 
+1

是的,它的varchar2列和TRIM不工作:( –

+0

似乎'chr(160)'不会像上面的注释中提到的那样被修剪。'update hr.countries t set t.country_name = t.country_name ||'' || chr(160);'修剪不会修剪这个。 – oey

0

将列类型从char更改为varchar2,char列将空值填充为空值填充字段大小。因此,对于一个char(10)列,当插入 'ABC',它会自动插入为 'ABC              '

0

使用UNISTR奏效了我。它删除了字符160和194

update mytab set mycol = REPLACE(mycol,unistr('\00A0'),'')