oracle中文ascii,Oracle 中文字符及中文乱码判断

Oracle里面如何识别存储字段里面是否存在中文?

方法一:

使用length和lengthb,如果中文的话length是一个字符,但是lengthb是两个字节。但是这个方法不适合数据库字符集非gbk的情况。

select * from t where length(c1) != lengthb(c1);

方法二:

使用asciistr函数得出是否字段里面包含“\”,因为当中文字符转换为ascii后,变成“\FFFD\FFFD”,但是需要注意一个特殊字符“\”,当它出现的时候转换后的码为“\005C”

SQL> select asciistr('/\)(^&*~中文字符') from dual;

ASCIISTR('/\)(^&*~中文字符')

-----------------------------------------------------------

/\005C)(

Oracle里面如何判断procedure等脚本里面是否包含中文乱码?

还是通过 asciistr 函数来实现了,如下:

SQL> select name, type

from user_source

where asciistr(text) like '%\FFFD%'

group by name, type;  2    3    4

NAME                   TYPE

---------------------- ------------

AGE_STAT_SUPERIOR      PROCEDURE

AUTOCREATE_SOURCE_DJ  PROCEDURE

AUTOCREATE__SOURCE_SJ  PROCEDURE

然后通过user_source加上上面的查询结果中的值,找得详细脚本

select text from user_source where name=upper('AGE_STAT_SUPERIOR');

附录:

The Oracle ASCIISTR Function

Definition:

The Oracle ASCIISTR function takes a string (or an expression that resolves to a string), in any and returns an ASCII version of the string in the current database character set.

The ASCIISTR function is useful for taking strings with accented characters (such as strings containing unicode characters) and converting them to an "ASCII-safe" format.

Example Usage:SELECT ASCIISTR('The letter Å will be converted.') asc_str

FROM dual;

This example returns the following string:The letter \00C5 will be converted.

Applies To:

Oracle 9i, Oracle 10g, Oracle 11g

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值