数据库表 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!!
本文介绍如何在数据库中区分并处理全角和半角字符,包括使用length和lengthb函数来识别全角数字,通过to_single_byte函数将全角字符转换为半角字符的方法,并给出具体的SQL语句实例。
2599

被折叠的 条评论
为什么被折叠?



