oracle 括号全角转半角,Oracle 表字段全角字符转换半角字符办法

如何把oracle表中的全角字符转换为半角字符?

a表包含全角字符的字段:address

update a set a.address =(to_single_byte(a.address))

执行,提交,即可。函数解释:

转换成半角函数: to_single_byte(s)

转换成全角函数:   to_multi_byte(s)

但是,to_single_byte(s)和to_multi_byte(s)函数发挥作用的前提是数据库字符集包括单字节字符和多字节字符。

oracle数据库安装的是GBK字符集,但是查看表的内码,发现表的数据是用unicode字符集存储的,暂时还未搞明白是怎么回事。。。。。

如果数据库不包含这些字符,需要用repalce()函数,分别手工去替换:

update a t set t.address = replace(t.address,'A','A')

update a t set t.address = replace(t.address,'B','B')

update a t set t.address = replace(t.address,'C','C')

update a t set t.address = replace(t.address,'D','D')

update a t set t.address = replace(t.address,'E','E')

update a t set t.address = replace(t.address,'F','F')

update a t set t.address = replace(t.address,'G','G')

update a t set t.address = replace(t.address,'H','H')

update a t set t.address = replace(t.address,'I','I')

update a t set t.address = replace(t.address,'J','J')

update a t set t.address = replace(t.address,'K','K')

update a t set t.address = replace(t.address,'L','L')

update a t set t.address = replace(t.address,'M','M')

update a t set t.address = replace(t.address,'N','N')

update a t set t.address = replace(t.address,'O','O')

update a t set t.address = replace(t.address,'P','P')

update a t set t.address = replace(t.address,'Q','Q')

update a t set t.address = replace(t.address,'R','R')

update a t set t.address = replace(t.address,'S','S')

update a t set t.address = replace(t.address,'T','T')

update a t set t.address = replace(t.address,'U','U')

update a t set t.address = replace(t.address,'V','V')

update a t set t.address = replace(t.address,'W','W')

update a t set t.address = replace(t.address,'X','X')

update a t set t.address = replace(t.address,'Y','Y')

update a t set t.address = replace(t.address,'Z','Z')

update a t set t.address = replace(t.address,'-','-')

update a t set t.address = replace(t.address,'0','0')

update a t set t.address = replace(t.address,'1','1')

update a t set t.address = replace(t.address,'2','2')

update a t set t.address = replace(t.address,'3','3')

update a t set t.address = replace(t.address,'4','4')

update a t set t.address = replace(t.address,'5','5')

update a t set t.address = replace(t.address,'6','6')

update a t set t.address = replace(t.address,'7','7')

update a t set t.address = replace(t.address,'8','8')

update a t set t.address = replace(t.address,'9','9')

手工写入这些好麻烦,有没有自动化的一点的办法?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值