sql
  1. sql-upper-function

SQL String Functions: UPPER Function

The UPPER function is a string function used to convert all alphabetic characters in a string to uppercase.

Syntax

The syntax for the UPPER function is as follows:

UPPER(string)

Where string is the input string value.

Example

Let's see an example of the UPPER function:

SELECT UPPER('Hello, World!') AS uppercase_string;

Output:

UPPERCASE_STRING
----------------
HELLO, WORLD!

Explanation

The UPPER function converts all lowercase alphabetic characters in the input string value to uppercase. The function is useful when we want to convert all characters in a string to uppercase, regardless of whether they are already uppercase or lowercase.

Use

The UPPER function can be used in various scenarios, such as:

  • Converting email addresses or usernames to a standard format
  • Making text more uniform
  • Comparing two strings in a case-insensitive manner

Important Points

  • The UPPER function does not change the original string. It returns a new string with all lowercase alphabetic characters converted to uppercase.
  • The function is case-sensitive. Non-alphabetic characters and uppercase alphabetic characters will not be affected by the function.

Summary

The UPPER function is a useful SQL string function that converts all alphabetic characters in a string to uppercase. It can be used in a variety of scenarios, such as standardizing text or comparing strings in a case-insensitive manner. Remember that the function only affects lowercase alphabetic characters and is case-sensitive.

Published on: