How SQLite Upper() Works

The SQLite upper() function allows you to convert a string to uppercase characters.

More precisely, it returns a copy of its argument, with all ASCII characters converted to uppercase.

Example

Here’s a basic example to demonstrate.

SELECT upper('No Shouting Please');

Result:

NO SHOUTING PLEASE

Database Example

Here’s an example of using the upper() function in a query against a database column.

SELECT 
  ProductName,
  upper(ProductName)
FROM Products;

Result:

ProductName            upper(ProductName)   
---------------------  ---------------------
Blue Widgets (6 Pack)  BLUE WIDGETS (6 PACK)
Widget Holder          WIDGET HOLDER        
Widget Opener          WIDGET OPENER        
Foobar Set             FOOBAR SET           
Red Widget             RED WIDGET           

Here, the left column contains the original value, and the right column contains those values converted to uppercase.

Number of Arguments

The upper() function requires one, and only one, argument.

If you provide no arguments, you’ll get an error.

SELECT upper();

Result:

Error: wrong number of arguments to function upper()

And if you provide too many arguments, you’ll also get an error.

SELECT upper('Gelato', 'Shop');

Result:

Error: wrong number of arguments to function upper()

Non-ASCII Characters

As mentioned, upper() only works on ASCII characters (the 26 letters used in the English language). SQLite only understands upper/lower case for ASCII characters by default.

You can load the SQLite ICU extension if you need to do case conversions on non-ASCII characters.

The ICU based functions provided by this extension provide case mapping, where defined, for the full range of unicode characters.