1. 程式人生 > >ORACLE 全形數字轉半形數字

ORACLE 全形數字轉半形數字

資料庫表 test 欄位 id  name age

全形數字:123456

半形數字:123456

length和lengthb的區別:

length(123456)             6

lengthb(123456)    12

to_single_byte函式用法:

to_single_byte(123456)   123456

查詢所有全形的數字:

select age from test where lengthB(age) >6

替換全形的為半形的:

update test  t1 set t1.age = (select to_single_byte(t2.age) from test  t2 where t1.id = t2.id)

ok!!

轉載自:http://lkfnn.iteye.com/blog/200416