CHR

CHR is an SQL function used to return the character that represents a specified ASCII value.

CHR(N)

  • n: This is an integer parameter that represents the Unicode value of the character this function returns. It ranges from 0 to 65535. The CHR(N) function converts the Unicode integer to a character before returning it.

Example

SELECT CHR(65) FROM dual;

Output

A

Explanation

The CHR function in Oracle SQL returns the character based on the ASCII value. In the example, CHR(65) converts the ASCII value 65 to the corresponding character, which is ‘A’.

CHR(integer_code) RETURNS text

  • integer_code: This is the numeric Unicode value of the character to return. It represents the Unicode point of the character in decimal format. The function, CHR(integer_code), interprets this value and returns the corresponding character as a text string.

Example

SELECT CHR(65) as output;

Output

output
--------
A

Explanation

In this example, the PostgreSQL function CHR is used to display the character that corresponds to the ASCII code ‘65’, which is ‘A’.

CHR(X)

  • x: This parameter represents an integer input value for the CHR(X) function. This integer value is the Unicode code point for the character that the function will return.

Example

SELECT CHR(65);

Output

A

Explanation

In SQLite, the CHR() function returns a string which represents the Unicode character that is the numeric value of the provided argument. In this example, CHR(65) returns ‘A’ because the Unicode numeric value of ‘A’ is 65.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.