Purpose
The ASCII function returns the ASCII value of the leftmost character of the character expression.
Syntax
ASCII(char)
Parameters
| Parameter | Description |
|---|---|
| char | An expression of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type. |
Return type
Returns the NUMBER data type.
Examples
Use the ASCII function to return the ASCII values of A, a, and a space.
obclient> SELECT ASCII('A') A, ASCII('a') a, ASCII(' ') space FROM DUAL;
+------+------+-------+
| A | A | SPACE |
+------+------+-------+
| 65 | 97 | 32 |
+------+------+-------+
1 row in set
Use the ASCII function to return the ASCII values of the A , a , Chinese , and space characters.
obclient> SELECT ASCII('A') A, ASCII('a') a, ASCII(' ') space,ASCII('Z') letter FROM DUAL;
+------+------+-------+----------+
| A | A | SPACE | HZ |
+------+------+-------+----------+
| 65 | 97 | 32 | 14989485 |
+------+------+-------+----------+
1 row in set