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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.