ASCII(x) gets the ASCII value of the character x,CHR() and ASCII() have the opposite effect.
作用:ascii函数将字符转换成其对应的ascii码,而chr函数将数字转换成对应的acscii码字符。
例子:
SELECT ASCII('a'), ASCII('A'),ASCII('0') from dual
结果:
ASCII('a') ASCII('A') ASCII('0')
97 65 48
------------------------------------------------
例子:
select chr(65) from dual
结果:
CHR(65)
A
-------------------------------------------------------------
值得注意的是:Ascii gives the ASCII value of the first character of a string。也即是说他只对一个字符串中的第一个字符起作用,你弄多长的字符串放进去它也只认第一个字符。
例子:
SELECT ASCII('food') FROM dual; 和语句SELECT ASCII('f') FROM dual;等价
结果:
为:102
参考资料:http://www.java2s.com/Tutorial/Oracle/0220__Character-String-Functions/ASCIIxgetstheASCIIvalueofthecharacterx.htm