SQL UPPER Function

Quick summary: The SQL UPPER() function converts a string to uppercase.

SQL UPPER Syntax

UPPER(string)
SQL

SQL UPPER Basic examples

SELECT UPPER('hello');
SQL
Output:
HELLO

Converts text to uppercase.

SQL UPPER Real-world usage

SELECT * FROM users WHERE UPPER(country) = 'USA';
SQL
Output:
Users from USA

Implements case-insensitive comparisons.

SQL UPPER Edge cases

SELECT UPPER(NULL);
SQL
Output:
NULL

Returns NULL when input is NULL.

SQL UPPER Common mistakes

Using UPPER in WHERE on indexed columns

Applying functions disables index usage.

Incorrect
WHERE UPPER(email) = 'A@TEST.COM'
Correct
WHERE email = 'a@test.com' COLLATE utf8mb4_general_ci

Use case-insensitive collation instead.

SQL UPPER Frequently Asked Questions

What does UPPER() do in SQL?

Converts a string to uppercase.

Use case of UPPER()?

Case-insensitive comparisons.

Syntax?

UPPER(string).

Common mistake?

Breaking index usage.

Return type?

String.

Handles NULL?

Returns NULL.

Performance?

Can disable indexes.

Alternative?

ILIKE (PostgreSQL).

Used in WHERE?

Yes.

Supports multibyte?

Depends on DB.

Used in search?

Yes.

Best practice?

Use normalized columns.

SQL UPPER Related SQL Keywords