lower(text) — Convert a string to lower case
Last updated: 2026-11-04
lower(text) — Convert a string to lower case
lower() returns the string with all letters converted to lower case. It is the standard way to normalise user-supplied emails, SKUs or hostnames so that equality lookups and unique indexes behave predictably instead of storing "Alice" and "alice" as two different rows.
| Kind | function |
|---|---|
| Example Language | SQL |
📝 Syntax
lower(string text) → text
⚙️ Parameters
| string text | The string to convert. Type text. |
|---|
Returns:text — the converted string. Returns NULL for a NULL input.
▶ Example
Runs real PostgreSQL 18 right in your browser (PGlite WASM, nothing to install). Press ▶ Run and the result appears in the panel below.
Output:
id | email | email_lower | city_lower
----+-------------------+-------------------+------------
1 | Alice@Example.COM | alice@example.com | beijing
2 | bob@example.com | bob@example.com | shanghai
3 | CAROL@EXAMPLE.COM | carol@example.com |
(3 rows)
📌 Key Points
- lower() converts letters only — digits, punctuation and whitespace are unchanged.
- A NULL input produces NULL.
- For a unique index to actually prevent duplicates, index the expression lower(email) rather than the raw column.
💡 Related Cases
More case studies coming soon.
📚 Related Reference
❓ FAQ
QIf I always query with lower(), do I still need a case-insensitive index?
AYes — index the expression: CREATE UNIQUE INDEX ON t (lower(email)). The query condition has to match the indexed expression for the index to be used.