How UPPER() Works in MariaDB

In MariaDB, UPPER() is a built-in string function that returns its string argument with all characters changed to uppercase.

The result is returned in the current character set mapping. The default is latin1 (cp1252 West European).

Another MariaDB function, UCASE() is a synonym for UPPER().

Syntax

The syntax goes like this:

UPPER(str)

Where str is the string to convert to uppercase.

Example

Here’s a basic example:

SELECT UPPER('Coffee');

Result:

+-----------------+
| UPPER('Coffee') |
+-----------------+
| COFFEE          |
+-----------------+

A Database Example

Here’s an example of converting the results of a database query to uppercase:

SELECT 
    PetName, 
    UPPER(PetName) 
FROM Pets;

Result:

+---------+----------------+
| PetName | UPPER(PetName) |
+---------+----------------+
| Fluffy  | FLUFFY         |
| Fetch   | FETCH          |
| Scratch | SCRATCH        |
| Wag     | WAG            |
| Tweet   | TWEET          |
| Fluffy  | FLUFFY         |
| Bark    | BARK           |
| Meow    | MEOW           |
+---------+----------------+

Binary Strings

The UPPER() function doesn’t work on binary strings (BINARY, VARBINARY, BLOB).

Example:

SELECT UPPER(BINARY 'Coffee');

Result:

+------------------------+
| UPPER(BINARY 'Coffee') |
+------------------------+
| Coffee                 |
+------------------------+

Null Arguments

Passing null returns null:

SELECT UPPER(null);

Result:

+-------------+
| UPPER(null) |
+-------------+
| NULL        |
+-------------+

Missing Argument

Calling UPPER() without passing any arguments results in an error:

SELECT UPPER();

Result:

ERROR 1582 (42000): Incorrect parameter count in the call to native function 'UPPER'