string
UPPER
Converts a string to uppercase using the current collation/locale. The mirror of LOWER, and equally universal across dialects.
UPPER(string) Parameters / Modifiers
| Parameter | Purpose |
|---|---|
| COLLATE ... | Apply a specific locale's uppercase rules |
| INITCAP | Postgres: title-case each word (John Doe) |
| UCASE | MySQL alias of UPPER |
Examples
SELECT UPPER('hello'); Returns 'HELLO'
SELECT UPPER(country_code) FROM users; Normalize ISO country codes to uppercase
SELECT INITCAP('john doe'); Postgres bonus: title-case each word ('John Doe')
SELECT UPPER('ß'); Postgres returns 'SS'; MySQL returns 'ß' (no case mapping)
Dialect notes / Gotcha
MySQL does not fold some multibyte characters that Postgres does (e.g. ß→SS). Wrapping a column in UPPER() bypasses B-tree indexes without a functional index.
Related functions
LOWER
Converts a string to lowercase using the database's active collation/locale. Universally supported and safe for normalizing case-insensitive lookups.
TRIM
Removes matching characters from the start, end, or both sides of a string. Defaults to stripping spaces when no character set is supplied.
REPLACE
Replaces every occurrence of from_str inside source with to_str. Case-sensitive in Postgres and SQLite; MySQL follows the column's collation.
CONCAT
Joins two or more strings end-to-end and returns a single string. CONCAT is portable across MySQL, Postgres 9.1+, and SQLite 3.44+; the standard || operator works in Postgres and SQLite but not MySQL unless PIPES_AS_CONCAT is set.
LENGTH / CHAR_LENGTH
Returns the number of characters in a string (CHAR_LENGTH) or the number of bytes (LENGTH in MySQL). Postgres and SQLite LENGTH return character count for text, matching CHAR_LENGTH.
← All SQL functions · SQL cheat sheet · Window functions · PostgreSQL cheat sheet