MariaDB UCASE() Function

In MariaDB, UCASE() is a built-in string function that converts the given string argument to uppercase and returns the result.

MariaDB UCASE() is an alias for UPPER().

If you want to convert a string to lowercase, use LCASE() or LOWER().

MariaDB UCASE() Syntax

Here is the syntax of the MariaDB UCASE() function:

UCASE(str)

Parameters

str

Required. The string to be processed.

If you do not provide a parameter, MariaDB will report an error: ERROR 1582 (42000): Incorrect parameter count in the call to native function 'UCASE'.

Return value

The UCASE(str) function returns the uppercase form of the specified string.

The UCASE() function returns NULL if the argument str is NULL.

NOTE: UCASE() does not work with binary strings.

MariaDB UCASE() Examples

Basic example

This statement shows the basic usage of the MariaDB UCASE() function:

SELECT UCASE('Hello'), UCASE(NULL);

Output:

+----------------+--------------------------+
| UCASE('Hello') | UCASE(NULL)              |
+----------------+--------------------------+
| HELLO          | NULL                     |
+----------------+--------------------------+

Here, the UCASE() function will return NULL if the argument is NULL.

Database example

This statement displays the first_name columns in the customer table in the Sakila sample database as uppercase:

SELECT UCASE(first_name) `First Name`
FROM customer
LIMIT 5;

Output:

+------------+
| First Name |
+------------+
| MARY       |
| PATRICIA   |
| LINDA      |
| BARBARA    |
| ELIZABETH  |
+------------+

Conclusion

The MariaDB UCASE() function converts a string to uppercase.