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
Syntax
chr(code) | ascii(string)
Parameters
| Parameter | Description |
|---|---|
code |
A Unicode code point. |
Return value
A one-character text value.
Examples
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.
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
Related
||· Join strings with the || operator. If either side is NULL the result is NULL; use concat() to skip NULLs instead.- SQL String Functions · tutorial