String Functions

PostgreSQL includes several functions that modify string-related data. These functions are particularly useful for controlling output displays and/or normalizing data input.

ASCII

Description

The ASCII function returns the ASCII value for the supplied character.

Inputs
ASCII(chr) 

chr—The character to determine the ASCII value of.

Examples
ASCII('A') → 65 
ASCII('Apple') → 65 
Notes

In the case of multiple characters being supplied to the ASCII function, only the first is evaluated.

CHR

Description

The CHR function returns the character that corresponds to the ASCII value provided.

Inputs
CHR(val) 

val—An ASCII value.

Example
CHR(65) → 'A' 

INITCAP

Description

The INITCAP function forces a string or column to be ...

Get PostgreSQL Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.