Lesson

MySQL UPPER() Function

10 min reading
Free Course

MySQL UPPER() Function

The UPPER() function converts every lowercase character in a string to uppercase according to the string's character set rules. It follows the ANSI SQL standard and behaves identically to MySQL's UCASE() alias.

Syntax

UPPER(str)
  • str: Character string, expression, or column.
  • Return value: Uppercased text string, or NULL if str is NULL.

When tables use utf8mb4, UPPER() properly converts international characters such as 'zürich' into 'ZÜRICH'.

Practical Example

Suppose shipping labels built from demo_customers require uppercase country names and postal_code strings before printing customs forms.

SELECT
    customer_id,
    UPPER(country) AS customs_country,
    UPPER(postal_code) AS clean_postal
FROM demo_customers
ORDER BY customer_id;
customer_id customs_country clean_postal
1 CANADA M5V 2T6
2 GERMANY 10115
3 NULL NULL

Row 1 turns lowercase 'm5v 2t6' into 'M5V 2T6', while row 3 keeps NULL inputs as NULL.

Common Mistakes & NULL Behavior

  • Disabling index lookups in WHERE: Writing WHERE UPPER(postal_code) = 'M5V 2T6' bypasses a standard B-tree index on postal_code. In MySQL 8.0+, either rely on a case-insensitive collation or define a functional index ((UPPER(postal_code))).
  • Expecting UPPER() to transform BLOB or BINARY columns: Binary types have no character set mapping, so UPPER() leaves them lowercase. Convert to utf8mb4 first with CONVERT(col USING utf8mb4).
  • NULL input: UPPER(NULL) returns NULL.

Frequently Asked Questions

Is UPPER() faster or more standard than UCASE()?

Performance is identical in MySQL. UPPER() is preferred because it follows standard SQL and runs unmodified in PostgreSQL, Oracle, SQL Server, and SQLite.

How do I capitalize only the first letter of a word?

Combine UPPER(LEFT(col, 1)) with LOWER(SUBSTRING(col, 2)) inside CONCAT().

Does UPPER() change the string length?

Usually no, though certain Unicode characters (like German 'ß' expanding to 'SS' under specific collations) can increase character count.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Try it Yourself

Experiment with the code from this lesson in our interactive playground.

Open Playground
MySQL Topic Hub

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum