Convert the input string to Title Case.
TO_TITLE_CASE(str)
## Overview Returns the input string with the first letter of every word uppercased and the remaining letters lowercased. Word boundaries are detected at spaces, underscores, and hyphens. Use this function to format display labels derived from raw, mixed-case input. ## Behavior - Returns NULL if the input is NULL. - Empty input returns an empty string. - Separators (spaces, underscores, hyphens) are preserved in their original positions. - Each word gets one uppercase letter at its start; the rest are lowercased. - Deterministic and side effect free. ## Compatibility - Matches the PG-compat TO_TITLE_CASE semantics. Similar to INITCAP but recognizes underscores and hyphens as word boundaries.
| Name | Type | Description |
|---|---|---|
str | Specifies the input string. Word boundaries are detected at spaces, underscores, and hyphens. |
-- Basic conversion
SELECT TO_TITLE_CASE('hello world'); -- 'Hello World'
-- From ALL CAPS
SELECT TO_TITLE_CASE('NEW YORK CITY'); -- 'New York City'
-- From snake_case
SELECT TO_TITLE_CASE('first_name'); -- 'First Name'
-- Format a display name for a report
SELECT TO_TITLE_CASE(city) AS display_city
FROM crm.catalog.addresses;
-- NULL propagation
SELECT TO_TITLE_CASE(NULL); -- NULL