UCASE/UPPER
Description
The UCASE function (alias UPPER) converts all lowercase letters in a string to uppercase letters. This function supports Unicode character conversion and can correctly handle case conversion rules for various languages.
Syntax
UCASE(<str>)
UPPER(<str>)
Parameters
| Parameter | Description |
|---|---|
<str> | The string to convert to uppercase. Type: VARCHAR |
Return Value
Returns VARCHAR type, representing the string converted to uppercase letters.
Conversion rules:
- Converts all lowercase letters in the string to corresponding uppercase letters
- Non-letter characters (numbers, symbols, spaces, etc.) remain unchanged
- Letters already in uppercase remain unchanged
Special cases:
- Returns NULL if parameter is NULL
- Returns empty string if string is empty
- Returns original string if there are no lowercase letters
Examples
- Basic English letter conversion
SELECT UCASE('aBc123'), UPPER('aBc123');
+-----------------+-----------------+
| UCASE('aBc123') | UPPER('aBc123') |
+-----------------+-----------------+
| ABC123 | ABC123 |
+-----------------+-----------------+
- Mixed character handling
SELECT UCASE('Hello World!'), UPPER('test@123');
+----------------------+------------------+
| UCASE('Hello World!') | UPPER('test@123') |
+----------------------+------------------+
| HELLO WORLD! | TEST@123 |
+----------------------+------------------+
- NULL value handling
SELECT UCASE(NULL), UPPER(NULL);
+-------------+-------------+
| UCASE(NULL) | UPPER(NULL) |
+-------------+-------------+
| NULL | NULL |
+-------------+-------------+
- Empty string handling
SELECT UCASE(''), UPPER('');
+-----------+-----------+
| UCASE('') | UPPER('') |
+-----------+-----------+
| | |
+-----------+-----------+
- Already uppercase string
SELECT UCASE('ALREADY UPPERCASE'), UPPER('ABC123');
+---------------------------+----------------+
| UCASE('ALREADY UPPERCASE') | UPPER('ABC123') |
+---------------------------+----------------+
| ALREADY UPPERCASE | ABC123 |
+---------------------------+----------------+
- Numbers and symbols
SELECT UCASE('123!@#$%'), UPPER('price: $99.99');
+-------------------+----------------------+
| UCASE('123!@#$%') | UPPER('price: $99.99') |
+-------------------+----------------------+
| 123!@#$% | PRICE: $99.99 |
+-------------------+----------------------+
- UTF-8 multi-byte characters
SELECT UCASE('ṭṛì test'), UPPER('ḍḍumai hello');
+--------------------+-----------------------+
| UCASE('ṭṛì test') | UPPER('ḍḍumai hello') |
+--------------------+-----------------------+
| ṬṚÌ TEST | ḌḌUMAI HELLO |
+--------------------+-----------------------+
- Cyrillic letters
SELECT UCASE('Кириллица'), UPPER('Бәйтерек');
+---------------------+-------------------+
| UCASE('Кириллица') | UPPER('Бәйтерек') |
+---------------------+-------------------+
| КИРИЛЛИЦА | БӘЙТЕРЕК |
+---------------------+-------------------+
Keywords
UCASE, UPPER