UPPER() – Convert to Uppercase in PostgreSQL

In PostgreSQL, we can use the upper() function to convert lowercase characters to their uppercase equivalent, according to the rules of the database’s locale.

Syntax

The syntax goes like this:

upper ( text )

Where text is the text to be converted to uppercase.

Example

SELECT upper('Louder!');

Result:

LOUDER!

Any uppercase characters remain uppercase, while lowercase characters are converted to uppercase.

Database Example

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

SELECT 
    firstname,
    UPPER(firstname)
FROM Dogs;

Result:

+-----------+-------+
| firstname | upper |
+-----------+-------+
| Bark      | BARK  |
| Woof      | WOOF  |
| Ruff      | RUFF  |
| Wag       | WAG   |
+-----------+-------+

Here I converted the firstname column to its uppercase equivalent.

To convert the other way around (from uppercase to lowercase), we can use lower().