upper(text) — Convert a string to upper case
Last updated: 2026-11-04
upper(text) — Convert a string to upper case
upper() returns the string with all letters converted to upper case, which is handy for normalising values before comparison, for display labels and for case-insensitive matching. Only letters are affected — digits, punctuation and spacing are left untouched.
| Kind | function |
|---|---|
| Example Language | SQL |
📝 Syntax
upper(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 | name | upper_name
----+--------------+--------------
1 | USB C Hub | USB C HUB
2 | ssd 固态硬盘 | SSD 固态硬盘
3 | HDMI Cable | HDMI CABLE
(3 rows)
📌 Key Points
- upper() converts letters only — digits, punctuation and whitespace are unchanged.
- A NULL input produces NULL, not an empty string.
- The result depends on the database collation, so a few characters may map differently under a different locale.
💡 Related Cases
More case studies coming soon.
📚 Related Reference
❓ FAQ
QCan upper() and lower() be nested?
AYou can, but it is pointless: upper(lower(x)) is just upper(x). Use initcap() when you want a capitalised first letter of each word.