MariaDB UCASE() Explained

In MariaDB, UCASE() 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).

UCASE() is a synonym for UPPER().

Syntax

The syntax goes like this:

UCASE(str)

Where str is the string to convert to uppercase.

Example

Here’s a basic example:

SELECT UCASE('Freedom!!!');

Result:

+---------------------+
| UCASE('Freedom!!!') |
+---------------------+
| FREEDOM!!!          |
+---------------------+

A Database Example

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

SELECT 
    City, 
    UCASE(City) 
FROM Vendors;

Result:

+-------------+-------------+
| City        | UCASE(City) |
+-------------+-------------+
| Smith City  | SMITH CITY  |
| Edmonton    | EDMONTON    |
| Strict Town | STRICT TOWN |
| Timaru      | TIMARU      |
| Dunedin     | DUNEDIN     |
+-------------+-------------+

Binary Strings

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

Example:

SELECT UCASE(BINARY 'Library');

Result:

+-------------------------+
| UCASE(BINARY 'Library') |
+-------------------------+
| Library                 |
+-------------------------+

Null Arguments

Passing null returns null:

SELECT UCASE(null);

Result:

+-------------+
| UCASE(null) |
+-------------+
| NULL        |
+-------------+

Missing Argument

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

SELECT UCASE();

Result:

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