Oracle/SQL ASCII Function

Oracle ASCII FunctionOracle ASCII Function is used to get the NUMBER code that represents the character in ASCII. In other words, SQL ASCII Function returns the ASCII number of the character passed to it.


Oracle ASCII Function Syntax

SELECT ASCII (character)
FROM table_name;

In the above Oracle/SQL ASCII Function Syntax:-

  • character is a single character that is passed to the ASCII function.
  • If more than 1 character is passed to the ASCII function then ASCII function will return the ASCII value of the first character and ignore other characters.

Oracle ASCII Function – Using SQL SELECT Statement Example 1

Oracle ASCII Function is used with the SQL SELECT Statement to get the ASCII value of the character passed.

For example, the SQL ASCII Function query below returns the ASCII value of ‘a’.

SELECT ASCII ('a')
FROM dual;

Will return 97


Oracle ASCII Function – Using SQL SELECT Statement Example 2

The below SQL ASCII Function query returns the ASCII value of ‘abc’.

SELECT ASCII ('abc')
FROM dual;

Will also return 97 and ignore the ASCII values of b and c characters.


Oracle ASCII Function – Using SQL SELECT Statement Example 3

The below SQL ASCII Function query returns the ASCII value of ‘A’.

SELECT ASCII ('A')
FROM dual;

Will return 65


Tagged , , , , , , , , , , , . Bookmark the permalink.