PostgreSQL 18 reference · String Functions

PostgreSQL CHR() Function

Return the character for a Unicode code point, such as chr(65) for 'A'. ascii() does the reverse.

PostgreSQL 18

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

chr(code)  |  ascii(string)

Parameters

ParameterDescription
code A Unicode code point.

Return value

A one-character text value.

Examples

Codes and characters
SELECT chr(65) AS a, chr(233) AS e_acute, ascii('A') AS code_a, ascii('é') AS code_e;

Output

 a | e_acute | code_a | code_e
---+---------+--------+--------
 A | é       |     65 |    233
(1 row)

Run this on your computer — see “Get Started” for setup.

Insert a new line
SELECT 'line one' || chr(10) || 'line two' AS two_lines;

Output

 two_lines
-----------
 line one +
 line two
(1 row)

Run this on your computer — see “Get Started” for setup.

In other languages

Was this page helpful?