MySQL UCASE() Function

 

The UCASE() function in MySQL is used to convert a string to uppercase letters. It is equivalent to the UPPER() function.


Syntax

UCASE(text)

Parameters

Parameter Description
text Required. The string that you want to convert to uppercase.

Definition and Usage

  • The UCASE() function converts all characters in the specified string to uppercase.

Return Values

  • The function returns the string with all characters converted to uppercase.

Usage Examples

Example 1: Convert a string to uppercase

SELECT UCASE("SQL Tutorial is FUN!") AS UppercaseText;

Output:

UppercaseText
SQL TUTORIAL IS FUN!

Explanation: The entire string is converted to uppercase.

Example 2: Convert the CustomerName column values to uppercase

SELECT UCASE(CustomerName) AS UppercaseCustomerName
FROM Customers;

Output:

UppercaseCustomerName
JOHN DOE
JANE SMITH

Explanation: Each CustomerName in the Customers table is converted to uppercase.


Technical Details

  • Works in: MySQL 4.0 and later.
  • Return Type: String (uppercase version of the original string).

Key Notes

  • The UCASE() function works by converting all letters in the string to uppercase.
  • It is commonly used in scenarios where consistent capitalization is needed, such as formatting names, or when comparing strings in a case-insensitive manner.

Was this article helpful?