Movatterモバイル変換


[0]ホーム

URL:


You don’t need a vector database - just use Postgres for everything. Read the case study on switching from Pinecone to Neon
PostgreSQL Tutorial
PostgreSQL Tutorial

PostgreSQL UPPER() Function

Summary: in this tutorial, you will learn how to use the PostgreSQLUPPER() function to convert a string to uppercase.

Introduction to the PostgreSQL UPPER() function

TheUPPER() function converts a string to uppercase based on the rules of the database’s locale.

Here’s the syntax of theUPPER() function:

UPPER(text)

In this syntax,text is the input string that you want to convert to uppercase. Its type can beCHAR,VARCHAR, orTEXT.

TheUPPER() function returns a new string with all letters converted to uppercase.

TheUPPER() function returnsNULL if thetext isNULL.

Note that to convert a string to lowercase, you use theLOWER() function.

PostgreSQL UPPER() function examples

Let’s take some examples of using theUPPER() function.

1) Basic PostgreSQL UPPER() function example

The following example uses theUPPER() function to convert the stringPostgreSQL to uppercase:

SELECT UPPER('PostgreSQL');

Output:

upper------------ POSTGRESQL(1 row)

2) Using PostgreSQL UPPER() function with table data

We’ll use thecustomer table from thesample database:

PostgreSQL UPPER() Function - Sample Table The following example uses theUPPER() function to convert the first names of customers to uppercase:

SELECT  UPPER(first_name)FROM  customerORDER BY  first_name;

Output:

upper------------- AARON ADAM ADRIAN AGNES ALAN...

3) Using PostgreSQL UPPER() function in the WHERE clause

The following example uses theUPPER() function in theWHERE clause to find customers by last names, comparing them with the input string in uppercase:

SELECT  first_name,  last_nameFROM  customerWHERE  UPPER(last_name)= 'BARNETT';

Output:

first_name | last_name------------+----------- Carole     | Barnett(1 row)

Summary

  • Use theUPPER() function to return a new string with all the characters of the input string converted to uppercase.

Last updated on

Was this page helpful?
Thank you for your feedback!

[8]ページ先頭

©2009-2025 Movatter.jp