In MariaDB, we can use the UPPER()
function to convert lowercase characters to their uppercase equivalent.
We can alternatively use UCASE()
, which is a synonym of UPPER()
.
Example
SELECT UPPER('Important notice!');
Result:
IMPORTANT NOTICE!
Any uppercase characters remain uppercase, while lowercase characters are converted to uppercase.
As previously alluded to, the UCASE()
function does the same thing. Here’s UPPER()
and UCASE()
alongside each other:
SELECT
UPPER('superyacht'),
UCASE('superyacht');
Result:
+---------------------+---------------------+ | UPPER('superyacht') | UCASE('superyacht') | +---------------------+---------------------+ | SUPERYACHT | SUPERYACHT | +---------------------+---------------------+
Database Example
Here’s an example of converting the results of a database query to uppercase:
SELECT
Name,
UPPER(Name)
FROM City
LIMIT 10;
Result:
+----------------+----------------+ | Name | UPPER(Name) | +----------------+----------------+ | Kabul | KABUL | | Qandahar | QANDAHAR | | Herat | HERAT | | Mazar-e-Sharif | MAZAR-E-SHARIF | | Amsterdam | AMSTERDAM | | Rotterdam | ROTTERDAM | | Haag | HAAG | | Utrecht | UTRECHT | | Eindhoven | EINDHOVEN | | Tilburg | TILBURG | +----------------+----------------+
Here I converted the Name
column to its uppercase equivalent.
To convert the other way around (from uppercase to lowercase), we can use LOWER()
and its synonym LCASE()
.