SQL Keywords

SQL UPPER

What does the SQL UPPER function do?

UPPER converts a character expression to all uppercase letters.
Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Compatible dialects for SQL UPPER: Supported in PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite, Snowflake, Redshift, BigQuery, DB2, Teradata

SQL UPPER Full Explanation

UPPER is a scalar string function that returns the input text with every alphabetic character converted to its uppercase form. Non alphabetic characters remain unchanged. The function is deterministic and collation-aware, meaning the exact result can depend on the database's locale and character set. UPPER is frequently used for case-insensitive searches, comparisons, data normalization, and display formatting. Because it creates a new string value, indexes on the original column are not used unless a functional or generated column index exists. Watch for performance impacts when calling UPPER on large text columns inside predicates or joins.

SQL UPPER Syntax

UPPER(expression);

SQL UPPER Parameters

  • expression (string or character expression) - The value to transform to uppercase.

Example Queries Using SQL UPPER

-- Normalize email addresses for comparison
SELECT email, UPPER(email) AS email_upper
FROM users;

-- Case-insensitive filter
SELECT *
FROM customers
WHERE UPPER(country) = 'CANADA';

-- Create a computed column
ALTER TABLE products ADD name_upper AS (UPPER(product_name));

Expected Output Using SQL UPPER

  • Each query returns the same text but with all alphabetic characters capitalized
  • In the WHERE clause example, only rows whose country equals 'Canada', 'CANADA', or any other case variation match

Use Cases with SQL UPPER

  • Make comparisons case-insensitive without changing stored data
  • Standardize data before loading into a warehouse
  • Build searchable text keys or computed columns
  • Display headings or codes in uppercase for UI consistency

Common Mistakes with SQL UPPER

  • Forgetting that UPPER can prevent index use, slowing queries
  • Using UPPER on already indexed columns inside WHERE without a functional index
  • Assuming UPPER changes non-alphabetic characters—it does not
  • Expecting locale-specific rules (e.g., Turkish dotted I) to behave identically across databases

Related Topics

LOWER, INITCAP, COLLATE, ILIKE, UCASE, LCASE, UPPERCASE

First Introduced In

SQL-92

Frequently Asked Questions

How does SQL UPPER handle NULL values?

Returns NULL. Any NULL input yields NULL output.

Can I create an index that supports UPPER?

Yes. Most databases allow functional or generated column indexes. For example, in PostgreSQL: `CREATE INDEX idx_users_email_upper ON users (UPPER(email));`

Is UPPER affected by collation?

Yes. Collation determines how characters map to uppercase. Edge cases like Turkish dotted I may produce different results under different locales.

When should I avoid using UPPER?

Avoid it in large table predicates without supporting indexes, as it forces a full scan and may degrade performance.

Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.
Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo

Check out other commonly used SQL Keywords!