PostgreSQL Tutorial

  • Home
  • Stored Procedures
  • Triggers
  • Views
  • Interfaces
    • PostgreSQL PHP
    • PostgreSQL Python
    • PostgreSQL JDBC
  • Functions
    • Aggregate Functions
    • Date / Time Functions
    • String Functions
    • Math Functions
Home / PostgreSQL String Functions / PostgreSQL CHR

PostgreSQL CHR

The PostgreSQL CHR() function converts an integer ASCII code to a character or a Unicode code point to a UTF8 character.

Syntax

The following shows the syntax of the CHR() function:

1
CHR(num)

Arguments

The CHR() function requires one argument:

1) num

The num argument is an integer that is converted to the corresponding ASCII code.

It could be a Unicode code point which is converted to a UTF8 character.

Return Value

The CHR() function returns a character which is corresponding the the ASCII code value or Unicode code point.

Examples

The following example shows how to use the CHR() function to get the characters whose ASCII code value is 65 and 97:

1
2
3
SELECT
    CHR(65),
    CHR(97);

The query returns character A for 65 and a for 97:

PostgreSQL CHR - ASCII example

Here is an example of getting the UTF8 character based on the Unicode code point 937:

1
2
SELECT
    CHR(937);

The output for the Unicode code point 937 is Ω, which is what we expected.

PostgreSQL CHR - Unicode example

Remarks

To get the ASCII code or UTF-8 character of an integer, you use the ASCII() function.

In this tutorial, you have learned how to use the PostgreSQL CHR() function to get the character based on its ASCII value or Unicode code point.

Previous Tutorial: PostgreSQL ASCII
Next Tutorial: PostgreSQL Letter Case Functions

PostgreSQL String Functions

  • ASCII
  • CONCAT
  • CHR
  • FORMAT
  • LEFT
  • LENGTH
  • LPAD
  • MD5
  • POSITION
  • REGEXP_MATCHES
  • REGEXP_REPLACE
  • RIGHT
  • REPLACE
  • SPLIT_PART
  • SUBSTRING
  • TRANSLATE
  • TRIM

About PostgreSQL Tutorial

PostgreSQLTutorial.com is a website dedicated to developers and database administrators who are working on PostgreSQL database management system.

We constantly publish useful PostgreSQL tutorials to keep you up-to-date with the latest PostgreSQL features and technologies. All PostgreSQL tutorials are simple, easy-to-follow and practical.

Recent PostgreSQL Tutorials

  • PostgreSQL TRUNC
  • PostgreSQL ROUND
  • PostgreSQL Math Functions
  • PostgreSQL LOCALTIME
  • PostgreSQL LOCALTIMESTAMP
  • PostgreSQL CURRENT_TIMESTAMP
  • PostgreSQL CURRENT_TIME
  • PostgreSQL CURRENT_DATE
  • PostgreSQL Date Functions
  • PostgreSQL EXTRACT

More Tutorials

  • PostgreSQL Cheat Sheet
  • PostgreSQL Administration
  • PostgreSQL PHP
  • PostgreSQL Python
  • PostgreSQL JDBC
  • PostgreSQL Resources

Site Info

  • Home
  • About Us
  • Contact Us
  • Privacy Policy

Copyright © 2017 by PostgreSQL Tutorial Website. All Rights Reserved.