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
轉載于:https://blog.51cto.com/wanqiufeng/438193