LOWER() – Convert to Lowercase in PostgreSQL

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

Syntax

The syntax goes like this:

lower ( text )

Where text is the text to be converted to lowercase.

Example

SELECT lower('MOUSE');

Result:

mouse

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

SELECT lower('Mouse');

Result:

mouse

Database Example

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

SELECT 
    first_name,
    LOWER(first_name)
FROM actor
LIMIT 10;

Result:

+------------+-----------+
| first_name |   lower   |
+------------+-----------+
| PENELOPE   | penelope  |
| NICK       | nick      |
| ED         | ed        |
| JENNIFER   | jennifer  |
| JOHNNY     | johnny    |
| BETTE      | bette     |
| GRACE      | grace     |
| MATTHEW    | matthew   |
| JOE        | joe       |
| CHRISTIAN  | christian |
+------------+-----------+

Here I used the pagila sample database. This database stores actors first names in uppercase characters in the first_name column. Therefore I used the lower() function to convert the first_name column to its lowercase equivalent.

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