Convert the input string to lowerCamelCase.
TO_CAMEL_CASE(str)
## Overview Converts the input string to lowerCamelCase. Word boundaries are detected at spaces, underscores, and hyphens; each boundary is removed, the next character is uppercased, and the first character of the result is lowercased. Use this function to transform SQL-style identifiers into JavaScript/JSON-friendly names. ## Behavior - Returns NULL if the input is NULL. - Empty input returns an empty string. - Single-word input is returned lowercased. - Non-letter boundary characters (spaces, underscores, hyphens) are removed. - Existing camel-case input is preserved: internal uppercase letters remain uppercase. - Deterministic and side effect free. ## Compatibility - Matches the PG-compat TO_CAMEL_CASE semantics.
| Name | Type | Description |
|---|---|---|
str | Specifies the input string. Separators recognized for word splitting are spaces, underscores, and hyphens. |
-- Space-separated words
SELECT TO_CAMEL_CASE('hello world'); -- 'helloWorld'
-- From snake_case
SELECT TO_CAMEL_CASE('first_name'); -- 'firstName'
-- From kebab-case
SELECT TO_CAMEL_CASE('background-color'); -- 'backgroundColor'
-- Emit JSON-friendly keys from DB column names
SELECT TO_CAMEL_CASE(column_name) AS json_key
FROM information_schema.columns
WHERE table_name = 'orders';
-- NULL propagation
SELECT TO_CAMEL_CASE(NULL); -- NULL